Part Number Hot Search : 
FM25L04B CXA1479Q 6322F33 C7453 BGA43 SDM0565R 0M106 AWL6254
Product Description
Full Text Search
 

To Download HT86AR72 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  ht86axx/ht86arxx a/d type voice 8-bit mcu rev. 1.00 1 march 19, 2010 general description the devices are voice type series 8-bit high perfor- mance microcontrollers which include a voice synthesiser and tone generator. they are specifically designed for applications which require multiple i/os and sound effects, such as voice and melodies. they can provide various sampling rates and beats, tone levels, tempos for speech synthesisers and melody generators. they also include an integrated high quality, voltage type dac output, an integrated series protocol interface, multi-channel a/d converter and integrated power amplifier for speaker driving. the ex- ternal interrupt can be triggered with falling edges or both falling and rising edges. the devices are fully supported by the holtek range of fully functional development and programming tools, providing a means for fast and efficient product devel - opment cycles. features  ht86axx operating voltage: 2.0v~5.5v ht86arxx operating voltage: 2.2v~5.5v  system clock: 4mhz~8mhz  crystal and rc system oscillator  40 i/o pins  8k 16-bit program memory  384 8-bit data memory  768/1536k-bit voice rom size  36/72 sec voice length  external interrupt input  12-bit high quality voltage type d/a output  4 channels 12-bit resolution a/d converter  spi series protocol interface  integrated 1w power amplifier to drive 8  speaker  four 8-bit programmable timer with overflow interrupt and 7-stage prescaler  one optional 32768hz crystal oscillator for rtc time base  8-bit counter with 3-bit prescaler  watchdog timer function  8-level subroutine nesting  low voltage reset and low voltage detect function  integrated voice rom with various capacities  power-down function and wake-up feature reduce power consumption  up to 0.5  s instruction cycle with 8mhz system clock at v dd =5v  63 powerful instructions  44-pin qfp and 64-pin lqfp packages technical document  application note  ha0075e mcu reset and oscillator circuits application note
part no. vdd program memory data memory voice rom voice capacity i/o timer d/a stack package types ht86a36 2.0v~ 5.5v 8k 16 3848 968 36sec 40 8-bit 4 12-bit1 8 44qfp, 64lqfp ht86a72 1928 72sec HT86AR72 2.2v~ 5.5v note: voice length is estimated by 21k-bit data rate block diagram ht86axx/ht86arxx rev. 1.00 2 march 19, 2010       
                                         !             

"
       !           # #        
   $        $ % 
  # #   

     #     # #    & ' ( #   !         '    % #  )         #     )     
     (       & ' ( #   !        
  !          selection table the devices include a comprehensive range of features, with most features common to all devices. the main features distinguishing them are voice rom capacity and power supply voltage. the functional differences between the de - vices are shown in the following table. devices which include an a in their part number are mask type while devices which contain an r in their part number are otp type.
pin assignment ht86axx/ht86arxx rev. 1.00 3 march 19, 2010 * + , - . / 0  1 * 2 * * * + * , * - * . * / * 0 *  * 1 + 2 + * + + + , + - + . + / + 0 +  + 1 , 2 , * , + , , , -, ., /, 0 , , 1- 2- *- +- ,- -         
  2 
, 
+ 
* 
2   2   *   +   , (   * (   *  3    /   .   -  0  /  .  -  ,  +  *    (    (    (      4 ( 5   "  6  7 "  6  "  (   (   (  3 8 9  7 9  "  (    3 -  3 . (    7   3 /  
+  
* 
. * + , - . / 0  1 * 2 * * * + * , * - * . * / * 0 *  * 1 + 2 + * + + + , + - + . + / + 0 +  + 1 , 2 , * , + , , , -, ., /, 0, , 1- 2- * - +- ,- -  2 
, 
+ 
* 
2   2   *   +   , (   * (   *  3    /   .   -  0  /  .  -  ,  +  *    (    (    (      4 ( 5   "  6  7 "  6  "  (   (   (  3 8 9  7 9  "  (    3 -  3 . (    7   3 /  
+  
* 
. - 0 - / - . - - - , - + - * + * + + + , + - + . + / + 0 +  + 1 , 2 , * , + , , , - , . , / , 0 ,  , 1 - 2 / - / , / + / * / 2 . 1 .  . 0 . / . . . - . , . + . * . 2 - 1 -  * + , - . / 0  1 * 2 * * * + * , * - * . * / * 0 *  * 1 + 2          
  2 7
7
 *  +  ,  -  .  0 
, 
+ 
* 
2   2   *   +  3 ,  3  9  7 9  "  (    3 -  3 . (    7   3 /  
+  
*  3 0 
0 
/ 
.    (    (    (    (      4 ( 5   "  6  7 "  6  "  (   (   
- (  3 8 (   * (   *   ,  3 +  3 *  3 2   0   /   .   -  5 0  5 /  5 .  5 -  5 ,  5 +  5 *  5 2  / - 0 - / - . - - - , - + - * + * + + + , + - + . + / + 0 +  + 1 , 2 , * , + , , , - , . , / , 0 ,  , 1 - 2 / - / , / + / * / 2 . 1 .  . 0 . / . . . - . , . + . * . 2 - 1 -  * + , - . / 0  1 * 2 * * * + * , * - * . * / * 0 *  * 1 + 2  2 7
7
 *  +  ,  -  .  0 
, 
+ 
* 
2   2   *   +  3 ,  3  9  7 9  "  (    3 -  3 . (    7   3 /  
+  
*  3 0 
0 
/ 
.    (    (    (    (      4 ( 5   "  6  7 "  6  "  (   (   
- (  3 8 (   * (   *   ,  3 +  3 *  3 2   0   /   .   -  5 0  5 /  5 .  5 -  5 ,  5 +  5 *  5 2  /                 
                  

pad assignment ht86a36 chip size: 2655  2725 ( m) 2 * the ic substrate should be connected to vss in the pcb layout artwork. ht86axx/ht86arxx rev. 1.00 4 march 19, 2010 : 2 ; 2 < * + , - . / 0  1 * 2 * * * + * , * - * . * / * 0 *  * 1 + 2 + * + + + , + - + . + / + 0 +  + 1 , 2 , * , + , , - * - 2 , 1 ,  , 0 , / , . , - - . - - - , - + - / - 0 -  - 1 . 2 . * . + . , . - . . . / . 0 . . 1 / 2 / * / + / , / - / . / / / 0
pad coordinates unit: m pad no. pad name x y pad no. pad name x y 1 pa0 1141.487 1211.389 35 osc2 1175.250 400.731 2 pc3 1177.862 380.061 36 pe6 1175.250 296.331 3 pc2 1177.862 483.061 37 int 1175.250 201.331 4 pc1 1177.862 578.061 38 vss 1174.567 90.426 5 pc0 1177.862 681.061 39 pe5 1174.567 19.807 6 pd0 1150.059 789.182 40 pe4 1174.567 122.807 7 pd1 1150.059 892.182 41 vdd 1174.567 226.177 8 pd2 1150.059 987.182 42 xout 1174.450 794.097 9 pd3 1150.059 1090.182 43 xin 1174.450 897.097 10 vssa1 1215.319 1257.457 44 res 1174.450 992.097 11 vdda1 1008.914 1225.000 45 pe3 1166.013 1211.389 12 vref 906.508 1213.900 46 pe2 1063.013 1211.389 13 pc4 803.508 1213.900 47 pe1 941.513 1211.389 14 nc 672.868 1082.529 48 pe0 838.513 1211.389 15 nc 596.868 1082.529 49 pd7 743.513 1211.389 16 nc 520.868 1082.529 50 pd6 640.513 1211.389 17 nc 444.868 1082.529 51 pd5 545.513 1211.389 18 nc 368.868 1082.529 52 pd4 442.513 1211.389 19 vssa 220.317 1116.909 53 pb7 347.513 1211.389 20 vdda 113.217 1121.909 54 pb6 244.513 1211.389 21 aud_out 8.383 1151.309 55 pb5 149.513 1211.389 22 aud_in 156.311 1146.077 56 pb4 46.513 1211.389 23 vbias 289.311 1146.077 57 pb3 48.487 1211.389 24 sp+ 391.136 1101.247 58 pb2 151.487 1211.389 25 vssm 498.085 1101.247 59 pb1 246.487 1211.389 26 vddm 605.036 1101.247 60 pb0 349.487 1211.389 27 vddm 733.086 1101.247 61 pa7 444.487 1211.389 28 vssm 840.037 1101.247 62 pa6 547.487 1211.389 29 sp- 946.986 1101.247 63 pa5 642.487 1211.389 30 pc5 1174.567 1158.350 64 pa4 745.487 1211.389 31 pc6 1174.567 1055.350 65 pa3 840.487 1211.389 32 pc7 1174.567 960.350 66 pa2 943.487 1211.389 33 pe7 1174.567 857.350 67 pa1 1038.487 1211.389 34 osc1 1175.250 499.731 ht86axx/ht86arxx rev. 1.00 5 march 19, 2010
ht86a72 chip size: 2651  3078 ( m) 2 * the ic substrate should be connected to vss in the pcb layout artwork. ht86axx/ht86arxx rev. 1.00 6 march 19, 2010 : 2 ; 2 < * + , - . / 0  1 * 2 * * * + * , * - * . * / * 0 *  * 1 + 2 + * + + + , + - + . + / + 0 +  + 1 , 2 , * , + , , - * - 2 , 1 ,  , 0 , / , . , - - . - - - , - + - / - 0 -  - 1 . 2 . * . + . , . - . . . / . 0 . . 1 / 2 / * / + / , / - / . / / / 0
pad coordinates unit: m pad no. pad name x y pad no. pad name x y 1 pa0 1139.487 1389.643 35 osc2 1177.250 817.231 2 pc3 1175.862 556.476 36 pe6 1177.250 232.827 3 pc2 1175.862 659.476 37 int 1177.250 137.827 4 pc1 1175.862 754.476 38 vss 1176.567 27.172 5 pc0 1175.862 857.476 39 pe5 1176.567 82.881 6 pd0 1148.059 965.628 40 pe4 1176.567 185.881 7 pd1 1148.059 1068.682 41 vdd 1176.567 289.431 8 pd2 1148.059 1163.682 42 xout 1176.450 892.351 9 pd3 1148.059 1266.682 43 xin 1176.450 995.351 10 vssa1 1213.319 1433.997 44 res 1176.450 1090.351 11 vdda1 1009.034 1401.500 45 pe3 1141.513 1389.643 12 vref 906.613 1390.400 46 pe2 1038.513 1389.643 13 pc4 803.613 1390.400 47 pe1 943.513 1389.643 14 nc 671.507 1258.234 48 pe0 840.513 1389.643 15 nc 595.507 1258.234 49 pd7 745.513 1389.643 16 nc 519.507 1258.234 50 pd6 642.513 1389.643 17 nc 443.507 1258.234 51 pd5 547.513 1389.643 18 nc 367.507 1258.234 52 pd4 444.513 1389.643 19 vssa 218.317 1293.409 53 pb7 349.513 1389.643 20 vdda 111.217 1298.409 54 pb6 246.513 1389.643 21 aud_out 10.383 1327.809 55 pb5 151.513 1389.643 22 aud_in 158.311 1322.577 56 pb4 48.513 1389.643 23 vbias 261.311 1322.577 57 pb3 46.487 1389.643 24 sp+ 393.136 1277.747 58 pb2 149.487 1389.643 25 vssm 500.085 1277.747 59 pb1 244.487 1389.643 26 vddm 607.036 1277.747 60 pb0 347.487 1389.643 27 vddm 735.086 1277.747 61 pa7 442.487 1389.643 28 vssm 842.037 1277.747 62 pa6 545.487 1389.643 29 sp- 948.986 1277.747 63 pa5 640.487 1389.643 30 pc5 1176.567 1334.850 64 pa4 743.487 1389.643 31 pc6 1176.567 1231.850 65 pa3 838.487 1389.643 32 pc7 1176.567 1136.850 66 pa2 941.487 1389.643 33 pe7 1176.567 1033.850 67 pa1 1036.487 1389.643 34 osc1 1177.250 916.231 ht86axx/ht86arxx rev. 1.00 7 march 19, 2010
HT86AR72 chip size: 2580  5870 ( m) 2 * the ic substrate should be connected to vss in the pcb layout artwork. ht86axx/ht86arxx rev. 1.00 8 march 19, 2010 : 2 ; 2 < * + , - . / 0  1 * 2 * * * + * , * - * . * / * 0 *  * 1 + 2 + * + + + , + - + . + / + 0 +  + 1 , 2 , * , + , , - * - 2 , 1 ,  , 0 , / , . , - - . - - - , - + - / - 0 -  - 1 . 2 . * . + . , . - . . . / . 0 .  . 1 / 2 / * / + / , / - / . / / / 0
pad coordinates unit: m pad no. pad name x y pad no. pad name x y 1 pa0 1138.054 2785.633 35 osc2 1138.850 2171.224 2 pc3 1138.629 1952.576 36 pe6 1138.668 1669.854 3 pc2 1138.629 2055.576 37 int 1138.668 1574.854 4 pc1 1138.629 2150.576 38 vss 1138.985 1432.154 5 pc0 1138.629 2253.576 39 pe5 1138.985 1321.921 6 pd0 1110.826 2361.132 40 pe4 1138.985 1218.921 7 pd1 1110.826 2464.132 41 vdd 1138.900 1110.526 8 pd2 1110.826 2559.132 42 xout 1138.908 994.167 9 pd3 1110.826 2662.132 43 xin 1138.908 891.167 10 vssa1 1176.086 2827.757 44 res 1138.906 761.007 11 vdda1 968.465 2785.850 45 pe3 1142.946 2785.633 12 vref 873.465 2785.850 46 pe2 1039.946 2785.633 13 pc4 770.465 2785.850 47 pe1 944.946 2785.633 14 nc 638.243 2804.019 48 pe0 841.946 2785.633 15 nc 562.243 2804.019 49 pd7 746.946 2785.633 16 nc 486.243 2804.019 50 pd6 643.946 2785.633 17 nc 410.243 2804.019 51 pd5 548.946 2785.633 18 nc 334.243 2804.019 52 pd4 445.946 2785.633 19 vssa 232.480 2738.114 53 pb7 350.946 2785.633 20 vdda 131.115 2739.664 54 pb6 247.946 2785.633 21 aud_out 28.525 2739.664 55 pb5 152.946 2785.633 22 aud_in 120.644 2718.027 56 pb4 49.946 2785.633 23 vbias 223.644 2718.027 57 pb3 45.054 2785.633 24 sp+ 355.469 2673.197 58 pb2 148.054 2785.633 25 vssm 462.418 2673.197 59 pb1 243.054 2785.633 26 vddm 569.369 2673.197 60 pb0 346.054 2785.633 27 vddm 697.419 2673.197 61 pa7 441.054 2785.633 28 vssm 804.370 2673.197 62 pa6 544.054 2785.633 29 sp- 911.319 2673.197 63 pa5 639.054 2785.633 30 pc5 1138.900 2696.357 64 pa4 742.054 2785.633 31 pc6 1138.900 2593.357 65 pa3 837.054 2785.633 32 pc7 1138.900 2498.357 66 pa2 940.054 2785.633 33 pe7 1138.900 2395.357 67 pa1 1035.054 2785.633 34 osc1 1138.900 2274.826 ht86axx/ht86arxx rev. 1.00 9 march 19, 2010
pin description pin name i/o options description pa0~pa7 i/o wake-up, pull-high bidirectional 8-bit i/o port. each pin on this port can be configured as a wake-up input by a configuration option. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration options determine which pins on the port have a pull-high resistor. pb0~pb7 i/o pull-high bidirectional 8-bit i/o port. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration options determine which pins on the port have a pull-high resistor. pc0/ad0 pc1/ad1 pc2/ad2 pc3/ad3 pc4~pc7 i/o pull-high bidirectional 8-bit i/o port. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration options determine which pins on the port have a pull-high resistor. pins pc0~pc3 are pin-shared with a/d converter input pins ad0~ad3. pd0/scs pd1/sck pd2/sdi pd3/sdo pd4~pd7 i/o pull-high bidirectional 8-bit i/o port. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration options determine which pin on the port have a pull-high resistor. pins pd0~pd3 are pin-shared with spi interface pins scs, sck, sdi, sdo. pe0~pe7 i/o pull-high bidirectional 8-bit i/o port. software instructions determine if the pin is a cmos output or schmitt trigger input. configuration options determine which pins on the port have a pull-high resistor. aud_out o  audio output for driving an external transistor or for driving ht82v739 aud_in i  power amplifier input pin sp-, sp+  power amplifier output pins vbias o  voltage bias pin res i  schmitt trigger reset input. active low. int i falling edge trigger or falling/rising edge trigger external interrupt schmitt trigger input without pull-high resistor. a configuration option determines if the interrupt active edge is a falling edge only or both a falling and rising edge. osc1 osc2  crystal or rc osc1, osc2 are connected to an external rc network or external crystal, deter- mined by configuration option, for the internal system clock. if the rc system clock option is selected, pin osc2 can be used to measure the system clock at 1 / 4 frequency. xin xout  crystal connected to an external 32khz crystal vref i  a/d circuit reference voltage vdd  positive digital power supply vss  negative digital power supply, ground. vdda  positive dac circuit power supply vssa  negative dac circuit power supply, ground vdda1  positive a/d circuit power supply vssa1  negative a/d circuit power supply, ground vddm  positive power amp. power supply vssm  negative power amp. power supply, ground note: 1. each pin on pa can be programmed through a configuration option to have a wake-up function. 2. individual pins can be selected to have pull-high resistors. ht86axx/ht86arxx rev. 1.00 10 march 19, 2010
absolute maximum ratings supply voltage ...........................v ss +2.0v to v ss +5.5v storage temperature ............................ 50 cto125 c input voltage..............................v ss  0.3v to v dd +0.3v operating temperature........................... 40 cto85 c i ol total ..............................................................150ma i oh total............................................................ 100ma total power dissipation .....................................500mw note: these are stress ratings only. stresses exceeding the range specified under  absolute maximum ratings  may cause substantial damage to the device. functional operation of this device at other conditions beyond those listed in the specification is not implied and prolonged exposure to extreme conditions may affect device reliability. d.c. characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions v dd ht86axx operating voltage  f sys =4mhz/8mhz 2.0  5.5 v v dd ht86arxx operating voltage  f sys =4mhz/8mhz 2.2  5.5 v i dd1 operating current 3v no load, f sys =4mhz, rtc enable, dac disable  1.5 ma 5v  5.0 ma 3v no load, f sys =8mhz, rtc enable, dac disable  3.0 ma 5v  7.0 ma i dd2 operating current 3v no load, f sys =4mhz, rtc enable, dac enable  10 ma 5v  18 ma 3v no load, f sys =8mhz, rtc enable, dac enable  20 ma 5v  36 ma i dd3 operating current 3v no load, f sys =4mhz, rtc disable, dac disable  1.5 ma 5v  5.0 ma 3v no load, f sys =8mhz, rtc disable, dac disable  3.0 ma 5v  7.0 ma i dd4 operating current 3v no load, f sys =4mhz, rtc disable, dac enable  10 ma 5v  18 ma 3v no load, f sys =8mhz, rtc disable, dac enable  20 ma 5v  36 ma i stb1 standby current 3v no load, system halt, wdt enable, rtc enable  5 a 5v  10 a i stb2 standby current 3v no load, system halt, wdt disable, rtc enable  2 a 5v  4 a i stb3 standby current 3v no load, system halt, wdt enable, rtc disable  4 a 5v  8 a i stb4 standby current 3v no load, system halt, wdt disable, rtc disable  1.0 a 5v  2.0 a v il1 input low voltage for i/o ports  0  0.3v dd v v ih1 input high voltage for i/o ports  0.7v dd  v dd v ht86axx/ht86arxx rev. 1.00 11 march 19, 2010
symbol parameter test conditions min. typ. max. unit v dd conditions v il2 input low voltage (res )  0  0.4v dd v v ih2 input high voltage (res )  0.9v dd  v dd v v lvr low voltage reset  lvr 2.1v option 2.0 2.1 2.2 v v lvd1 low voltage detect  lvd 2.2v 1.9  2.5 v v lvd2 low voltage detect  lvd 2.3v 2.0  2.6 v v lvd3 low voltage detect  lvd 2.4v 2.1  2.7 v v lvd4 low voltage detect  lvd 2.5v 2.2  2.8 v i ol1 i/o port sink current (for pa0~pa7, pb0~pb7, pc0~pc7, pd4~pd7, pe0~pe7) 3v v ol =0.1v dd 4  ma 5v 10  ma i oh1 i/o port source current (for pa0~pa7, pb0~pb7, pc0~pc7, pd4~pd7, pe0~pe7) 3v v oh =0.9v dd 2  ma 5v 5  ma i ol2 i/o port sink current (for pd0~pd3) 3v v ol =0.1v dd 8  ma 5v 20  ma i oh2 i/o port source current (for pd0~pd3) 3v v oh =0.9v dd 2  ma 5v 5  ma i aud aud source current 3v v oh =0.9v dd 1.5  ma 5v 3  ma r ph pull-high resistance 3v  20 60 100 k 5v 10 30 50 k v ad a/d input/output  0  v ref v v ref adc input reference voltage range 3v av dd =3v 1.3  av dd v 5v av dd =5v 1.5  av dd v dnl adc differential non-linear  av dd =5v, v ref =av dd , t ad =1s 
2.0 lsb inl adc integral non-linear  av dd =5v, v ref =av dd , t ad =1s 
2.5
4.0 lsb resolu resolution   12 bits i adc additional power consumption if a/d converter is used 3v no load, t ad =1s  0.5 1.0 ma 5v  1.5 3.0 ma ht86axx/ht86arxx rev. 1.00 12 march 19, 2010
a.c. characteristics ta=25 c symbol parameter test conditions min. typ. max. unit v dd conditions f sys system clock (rc osc, crystal osc)  ht86axx:2.0v~5.5v ht86arxx:2.2v~5.5v 4  8 mhz t wdtosc watchdog oscillator period 3v  45 90 180 s 5v  32 65 130 s t res external reset low pulse width  1  s t sst system start-up timer period  power-up or wake-up from halt  1024  *t sys t lvr low voltage reset time  2  ms t int interrupt pulse width  1  s t ad a/d clock period  1.0  s t adc a/d conversion time   80  t ad t adc a/d sampling time   32  t ad t mat circumscribe memory access time  ht86axx:2.0v~5.5v ht86arxx:2.2v~5.5v  400 ns note: *t sys =1/f sys characteristics curves ht86axx  r vs. f chart characteristics curves  t vs. f chart characteristics curves ht86axx/ht86arxx rev. 1.00 13 march 19, 2010          8   = $     :  > ? <   :   <  / - + * - / *   + 0 / , . 0 - 2 1 , @ 2 ( - @ . ( * 2   : 
< )  
)  
 : + . 
< 2 @ 1 * 2 @ 1 . 2 @ 1 1 * @ 2 , * @ 2 0 * @ * * * @ * .  / 2  - 2  + 2 2 + 2 - 2 / 2  2 * 2 2          (   a , ( (   a . ( (   a , ( (   a . (
 v vs. f chart characteristics curves  3.0v  v vs. f chart characteristics curves  4.5v ht86arxx  r vs. f chart characteristics curves ht86axx/ht86arxx rev. 1.00 14 march 19, 2010                  8   = $     :  > ? < (    : ( < + - /  + @ / , @ 2 , @ , , @  - @ + - @ . - @ 1 . @ + . @ . -  > ?  + 0 /   /  > ?  *       > ?  * - /   + @ + * 2                  8   = $     :  > ? < (    : ( < + @ + + @ / , @ 2 , @  - @ + - @ . . @ + . @ . , @ , - @ 1  / - + /  > ?  *  0     > ?  * - 2   -  > ?  + / 1   * 2          8   = $     :  > ? <   :   <  / - + - 1 / *  / * * * * , + , @ 2 ( - @ . ( * 2
 t vs. f chart characteristics curves  v vs. f chart characteristics curves  3.0v  v vs. f chart characteristics curves  4.5v ht86axx/ht86arxx rev. 1.00 15 march 19, 2010   : 
< )  
)  
 : + . 
< 2 @ 1 - 2 @ 1 / 2 @ 1  * @ 2 2 * @ 2 + * @ 2 / * @ * 2  / 2  - 2  + 2 2 + 2 - 2 / 2  2 * 2 2          (   a , ( (   a . ( (   a , ( (   a . ( * @ 2 - * @ 2                   8   = $     :  > ? < (    : ( < + - /  + @ / , @ 2 , @ , , @  - @ + - @ . - @ 1 . @ + . @ . + @ + * 2 -  > ?   /   /  > ?  / *     > ?  - 1                    8   = $     :  > ? < (    : ( < + @ + + @ / , @ 2 , @  - @ + - @ . . @ + . @ . , @ , - @ 1  / - + /  > ?  . .     > ?  - ,   -  > ?  0 1   * 2
ht86axx/ht86arxx rev. 1.00 16 march 19, 2010 system architecture a key factor in the high-performance features of the holtek range of voice microcontrollers is attributed to the internal system architecture. the range of devices take advantage of the usual features found within risc microcontrollers providing increased speed of operation and enhanced performance. the pipelining scheme is implemented in such a way that instruction fetching and instruction execution are overlapped, hence instructions are effectively executed in one cycle, with the exception of branch or call instructions. an 8-bit wide alu is used in practically all operations of the instruction set. it car - ries out arithmetic operations, logic operations, rotation, increment, decrement, branch decisions, etc. the inter - nal data path is simplified by moving data through the accumulator and the alu. certain internal registers are implemented in the data memory and can be directly or indirectly addressed. the simple addressing methods of these registers along with additional architectural fea - tures ensure that a minimum of external components is required to provide a functional i/o, voltage type dac, capacitor/resistor sensor input and external rc oscilla - tor converter with maximum reliability and flexibility. clocking and pipelining the main system clock, derived from either a crystal/ resonator or rc oscillator is subdivided into four inter- nally generated non-overlapping clocks, t1~t4. the program counter is incremented at the beginning of the t1 clock during which time a new instruction is fetched. the remaining t2~t4 clocks carry out the decoding and execution functions. in this way, one t1~t4 clock cycle forms one instruction cycle. although the fetching and execution of instructions takes place in consecutive in - struction cycles, the pipelining structure of the microcontroller ensures that instructions are effectively executed in one instruction cycle. the exception to this are instructions where the contents of the program counter are changed, such as subroutine calls or jumps, in which case the instruction will take one more instruction cycle to execute. when the rc oscillator is used, osc2 is freed for use as a t1 phase clock synchronizing pin. this t1 phase clock has a frequency of f sys /4 with a 1:3 high/low duty cycle. for instructions involving branches, such as jump or call instructions, two machine cycles are required to com - plete instruction execution. an extra cycle is required as the program takes one cycle to first obtain the actual jump or call address and then another cycle to actually execute the branch. the requirement for this extra cycle should be taken into account by programmers in timing sensitive applications. 8         @  : 
< 3 b   $       @  : 
 * < 8         @  : 
4 * < 3 b   $       @  : 
< 8         @  : 
4 + < 3 b   $       @  : 
4 * < 

4 * 
4 +     # #    
#   :       
#   <      
#     *   !    
$         
#     +      
#     ,      
#     -   %  #   ! system clocking and pipelining 8         @  * 3 b   $       @  * 8         @  + 8 # $      %  #   * + , - . /  3 & c d   (  ; e * + > f
& &   3 & c
 &  e * + > f d d 7   3 b   $       @  + 8         @  , 8         @  / 3 b   $       @  / 8         @  0 instruction fetching
ht86axx/ht86arxx rev. 1.00 17 march 19, 2010 program counter during program execution, the program counter is used to keep track of the address of the next instruction to be executed. it is automatically incremented by one each time an instruction is executed except for instructions, such as jmp or call , that demand a jump to a non-consecutive program memory address. note that the program counter width varies with the program memory capacity depending upon which device is se - lected. however, it must be noted that only the lower 8 bits, known as the program counter low register, are directly addressable by user. when executing instructions requiring jumps to non-consecutive addresses such as a jump instruction, a subroutine call, interrupt or reset, etc., the microcontroller manages program control by loading the required address into the program counter. for condi - tional skip instructions, once the condition has been met, the next instruction, which has already been fetched during the present instruction execution, is dis - carded and a dummy cycle takes its place while the cor - rect instruction is obtained. the lower byte of the program counter, known as the program counter low register or pcl, is available for program control and is a readable and writable register. by transferring data directly into this register, a short program jump can be executed directly, however, as only this low byte is available for manipulation, the jumps are limited to the present page of memory, that is 256 locations. when such program jumps are executed it should also be noted that a dummy cycle will be in- serted. the lower byte of the program counter is fully accessi - ble under program control. manipulating the pcl might cause program branching, so an extra cycle is needed to pre-fetch. further information on the pcl register can be found in the special function register section. stack this is a special part of the memory which is used to save the contents of the program counter only. the stack has 8 levels and is neither part of the data nor part of the program space, and is neither readable nor writable. the activated level is indexed by the stack pointer, sp, and is neither readable nor writable. at a subroutine call or interrupt acknowledge signal, the con - tents of the program counter are pushed onto the stack. at the end of a subroutine or an interrupt routine, sig - naled by a return instruction, ret or reti , the pro - gram counter is restored to its previous value from the stack. after a device reset, the stack pointer will point to the top of the stack. mode program counter *12 *11 *10 *9 *8 *7 *6 *5 *4 *3 *2 *1 *0 initial reset 0000000000000 external interrupt 0000000000100 timer 0 overflow 0000000001000 timer 1 overflow 0000000001100 timer 2 overflow 0000000010000 timer 3 overflow 0000000010100 a/d converter interrupt 0000000011000 skip program counter + 2 loading pcl *12 *11 *10 *9 *8 @7 @6 @5 @4 @3 @2 @1 @0 jump, call branch #12 #11 #10 #9 #8 #7 #6 #5 #4 #3 #2 #1 #0 return from subroutine s12 s11 s10 s9 s8 s7 s6 s5 s4 s3 s2 s1 s0 program counter note: *12~*0: program counter bits s12~s0: stack register bits #12~#0: instruction code bits @7~@0: pcl bits   !    
$          &   #  *       &   #  +       &   #  ,       &   #     !          %  )                 5     )      
ht86axx/ht86arxx rev. 1.00 18 march 19, 2010 if the stack is full and an enabled interrupt takes place, the interrupt request flag will be recorded but the ac - knowledge signal will be inhibited. when the stack pointer is decremented, by ret or reti, the interrupt will be serviced. this feature prevents stack overflow al - lowing the programmer to use the structure more easily. however, when the stack is full, a call subroutine in - struction can still be executed which will result in a stack overflow. precautions should be taken to avoid such cases which might cause unpredictable program branching. arithmetic and logic unit  alu the arithmetic-logic unit or alu is a critical area of the microcontroller that carries out arithmetic and logic op - erations of the instruction set. connected to the main microcontroller data bus, the alu receives related in - struction codes and performs the required arithmetic or logical operations after which the result will be placed in the specified register. as these alu calculation or oper - ations may result in carry, borrow or other status changes, the status register will be correspondingly up - dated to reflect these changes. the alu supports the following functions:  arithmetic operations add, addm, adc, adcm, sub, subm, sbc, sbcm, daa  logic operations and, or, xor, andm, orm, xorm, cpl, cpla  rotation rra, rr, rrca, rrc, rla, rl, rlca, rlc  increment and decrement inca, inc, deca, dec  branch decision jmp, sz, sza, snz, siz, sdz, siza, sdza, call, ret, reti program memory the program memory is the location where the user code or program is stored. structure the program memory stores the program instructions that are to be executed. it also includes data, table and interrupt entries, addressed by the program counter along with the table pointer. the program memory size is 8192  16 bits. certain locations in the program mem - ory are reserved for special usage. special vectors within the program memory, certain locations are re - served for special usage such as reset and interrupts.  location 000h this vector is reserved for use by the device reset for program initialisation. after a device reset is initiated, the program will jump to this location and begin execution.  location 004h this vector is used by the external interrupt. if the ex - ternal interrupt pin on the device goes low, the pro - gram will jump to this location and begin execution if the external interrupt is enabled and the stack is not full.  location 008h this internal vector is used by the 8-bit timer 0. if a overflow occurs, the program will jump to this location and begin execution if the timer interrupt is enabled and the stack is not full.  location 00ch this internal vector is used by the 8-bit timer1. if a overflow occurs, the program will jump to this location and begin execution if the timer interrupt is enabled and the stack is not full.  location 010h this internal vector is used by the 8-bit timer2. if a overflow occurs, the program will jump to this location and begin execution if the timer interrupt is enabled and the stack is not full.  location 014h this internal vector is used by the 8-bit timer3. if a overflow occurs, the program will jump to this location and begin execution if the timer interrupt is enabled and the stack is not full.  location 018h this internal vector is used by the a/d converter. if an a/d converter conversion completes, the program will jump to this location and begin execution if the a/d converter interrupt is enabled and the stack is not full. * 8 8 8 > * /      2 * 1 > 2 2 2 > 2 2 - > 2 2  > 2 2
> 2 * 2 >      #      (     3 b     #      $ %   (           2      $ %   (     2 * - >       *      $ %   (           ,      $ %   (           +      $ %   (     2 *  >   
          $ %   (     program memory structure
ht86axx/ht86arxx rev. 1.00 19 march 19, 2010 look-up table any location within the program memory can be defined as a look-up table where programmers can store fixed data. to use the look-up table, table pointers are used to setup the address of the data that is to be accessed from the program memory. however, as some devices possess only a low byte table pointer and other devices possess both a high and low byte pointer it should be noted that de - pending upon which device is used, accessing look-up ta - ble data is implemented in slightly different ways. for the devices, there are two table pointer registers known as tblp and tbhp in which the lower order and higher order address of the look-up data to be retrieved must be respectively first written. unlike the other de - vices in which only the low address byte is defined using the tblp register, the additional tbhp register allows the complete address of the look-up table to be defined and consequently allow table data from any address and any page to be directly accessed. for these de - vices, after setting up both the low and high byte table pointers, the table data can then be retrieved from any area of program memory using the  tabrdc [m] in - struction or from the last page of the program memory using the  tabrdl [m] instruction. when either of these instructions are executed, the lower order table byte from the program memory will be transferred to the user defined data memory register [m] as specified in the instruction. the higher order table data byte from the program memory will be transferred to the tblh special register. any unused bits in this transferred higher order byte will be read as 0. the following diagram illustrates the addressing/data flow of the look-up table for the devices: table program example the following example shows how the table pointer and table data is defined and retrieved from the devices. this example uses raw table data located in the last page which is stored there using the org statement. the value at this org statement is  1f00h which refers to the start address of the last page within the program memory of the microcontroller. the table pointer is setup here to have an initial value of  06h . this will ensure that the first data read from the data table will be at the pro - gram memory address  1f06h or 6 locations after the start of the last page. note that the value for the table pointer is referenced to the first address of the present page if the  tabrdc [m]  instruction is being used. the high byte of the table data which in this case is equal to zero will be transferred to the tblh register automatically when the  tabrdl [m]  instruction is executed.   !           5 &   5 & >  %    )       e  f >  !   5     )     #  
    & '  5     )     #  
     5 >  look-up table tempreg1 db ? ; temporary register #1 tempreg2 db ? ; temporary register #2 : : mov a,06h ; initialise table pointer - note that this address ; is referenced mov tblp,a ; to the last page or present page : : tabrdl tempreg1 ; transfers value in table referenced by table pointer ; to tempregl ; data at prog. memory address 1f06h transferred to ; tempreg1 and tblh dec tblp ; reduce value of table pointer by one tabrdl tempreg2 ; transfers value in table referenced by table pointer ; to tempreg2 ; data at prog.memory address 1f05h transferred to ; tempreg2 and tblh ; in this example the data 1ah is transferred to ; tempreg1 and data 0fh to register tempreg2 ; the value 00h will be transferred to the high byte ; register tblh : : org 1f00h ; sets initial address of ht86a72 last page dc 00ah, 00bh, 00ch, 00dh, 00eh, 00fh, 01ah, 01bh : :
ht86axx/ht86arxx rev. 1.00 20 march 19, 2010 because the tblh register is a read-only register and cannot be restored, care should be taken to ensure its protection if both the main routine and interrupt service routine use table read instructions. if using the table read instructions, the interrupt service routines may change the value of the tblh and subsequently cause errors if used again by the main routine. as a rule it is recommended that simultaneous use of the table read instructions should be avoided. however, in situations where simultaneous use cannot be avoided, the inter - rupts should be disabled prior to the execution of any main routine table-read instructions. note that all table related instructions require two instruction cycles to complete their operation. instruction table location *12 *11 *10 *9 *8 *7 *6 *5 *4 *3 *2 *1 *0 tabrdc [m] p12 p11 p10 p9 p8 @7 @6 @5 @4 @3 @2 @1 @0 tabrdl [m] 11111@7@6@5@4@3@2@1@0 table location note: *12~*0: current program rom table p12~p8: write p12~p8 to tbhp pointer register @7~@0: write @7~@0 to tblp pointer register data memory the data memory is a volatile area of 8-bit wide ram in - ternal memory and is the location where temporary in - formation is stored. divided into two sections, the first of these is an area of ram where special function registers are located. these registers have fixed locations and are necessary for correct operation of the device. many of these registers can be read from and written to di- rectly under program control, however, some remain protected from user manipulation. the second area of ram data memory is reserved for general purpose use. all locations within this area are read and write accessi- ble under program control. structure the data memory is subdivided into two banks, known as bank 0 and bank 1, all of which are implemented in 8-bit wide ram. most of the ram data memory is lo - cated in bank 0 which is also subdivided into two sec - tions, the special purpose data memory and the general purpose data memory. the start address of the ram data memory for all devices is the address 00h, and the last data memory address is ffh . registers which are common to all microcontrollers, such as acc, pcl, etc., have the same data memory address. note: most of the ram data memory bits can be directly manipulated using the  set [m].i and  clr [m].i in- structions with the exception of a few dedicated bits. the ram data memory can also be accessed through the memory pointer registers mp0 and mp1. general purpose data memory all microcontroller programs require an area of read/write memory where temporary data can be stored and retrieved for use later. it is this area of ram memory that is known as general purpose data memory. this area of data memory is fully accessible by the user pro - gram for both read and write operations. by using the  set [m].i and  clr [m].i instructions individual bits can be set or reset under program control giving the user a large range of flexibility for bit manipulation in the data memory. d  "  '  2 2 > - 2 > 8 8 > , 3 >  %     #   $  %             g     #   $  %             : * 1 +  5     < - 2 > 8 8 > g     #   $  %             : * 1 +  5     <  ! "   ! " # ram data memory structure  bank 0 and bank 1
ht86axx/ht86arxx rev. 1.00 21 march 19, 2010 special purpose data memory this area of data memory, is located in bank 0, where registers, necessary for the correct operation of the microcontroller, are stored. most of the registers are both readable and writeable but some are protected and are readable only, the details of which are located under the relevant special function register section. note that for locations that are unused, any read instruction to these addresses will return the value 00h . although the special purpose data memory registers are located in bank 0, they will still be accessible even if the bank pointer has selected bank 1. special function registers to ensure successful operation of the microcontroller, certain internal registers are implemented in the ram data memory area. these registers ensure correct op - eration of internal functions such as timers, interrupts, watchdog, etc., as well as external functions such as i/o data control. the location of these registers within the ram data memory begins at the address 00h . any unused data memory locations between these special function registers and the point where the general pur - pose memory begins is reserved for future expansion purposes, attempting to read data from these locations will return a value of 00h. indirect addressing register  iar0, iar1 the indirect addressing registers, iar0 and iar1, al - though having their locations in normal ram register space, do not actually physically exist as normal regis- ters. the method of indirect addressing for ram data manipulation uses these indirect addressing registers and memory pointers, in contrast to direct memory ad- dressing, where the actual memory address is speci- fied. actions on the iar0 and iar1 registers will result in no actual read or write operation to these registers but rather to the memory location specified by their corre- sponding memory pointer, mp0 or mp1. acting as a pair, iar0 and mp0 can together only access data from bank 0, while the iar1 and mp1 register pair can ac - cess data from both bank 0 and bank 1. as the indirect addressing registers are not physically implemented, reading the indirect addressing registers indirectly will return a result of 00h and writing to the registers indi - rectly will result in no operation. memory pointer  mp0, mp1 for all devices, two memory pointers, known as mp0 and mp1 are provided. these memory pointers are physically implemented in the data memory and can be manipulated in the same way as normal registers pro - viding a convenient way with which to address and track data. when any operation to the relevant indirect ad - dressing registers is carried out, the actual address that the microcontroller is directed to, is the address speci - fied by the related memory pointer. mp0, together with indirect addressing register, iar0, are used to access data from bank 0 only, while mp1 and iar1 are used to access data from both bank 0 and bank 1. d  "  '   2   2   *   * 5 


&  5 &   5 & >        "   7 
   2    2
   *    *
 
 5  5



& 
> 2 > & 
> 2  & 
> 2 & & 
> * > & 
> *  & 
> * &  7 
>  5 >     +    +
   ,    ,
(  
3
 &  > (  & & 
>     
  &   > 

  & ( 
 3  3
 5
  5   2 2 > 2 * > 2 + > 2 , > 2 - > 2 . > 2 / > 2 0 > 2  > 2 1 > 2 > 2 5 > 2
> 2  > 2 3 > 2 8 > * 2 > * * > * + > * , > * - > * . > * / > * 0 > *  > * 1 > * > * 5 > *
> *  > * 3 > * 8 > + 2 > + * > + + > + , > + - > + . > + / > + 0 > +  > + 1 > + > + 5 > +
> +  > + 3 > + 8 > , 2 > , * > , + > , , > , - > , . > , / > , 0 > ,  > , 1 > , > , 5 > ,
> ,  > special purpose data memory structure
ht86axx/ht86arxx rev. 1.00 22 march 19, 2010 the following example shows how to clear a section of four ram locations already defined as locations adres1 to adres4. data .section data adres1 db ? adres2 db ? adres3 db ? adres4 db ? block db ? code .section at 0 code org 00h start: mov a,04h ; setup size of block mov block,a mov a,offset adres1; accumulator loaded with first ram address mov mp0,a ; setup memory pointer with first ram address loop: clr iar0 ; clear the data at address defined by mp0 inc mp0 ; increment memory pointer sdz block ; check if last memory location has been cleared jmp loop continue: the important point to note here is that in the example shown above, no reference is made to specific ram addresses. bank pointer  bp the ram data memory is divided into two banks, known as bank 0 and bank 1. with the exception of the bp register, all of the special purpose registers and general purpose registers are contained in bank 0. if data in bank 0 is to be accessed, then the bp register must be loaded with the value "00", while if data in bank 1 is to be accessed, then the bp register must be loaded with the value 01. using memory pointer mp0 and indirect addressing register iar0 will always access data from bank 0, irre- spective of the value of the bank pointer. the data memory is initialised to bank 0 after a reset, except for the wdt time-out reset in the power down mode, in which case, the data memory bank remains unaffected. it should be noted that special function data memory is not affected by the bank selection, which means that the special function registers can be accessed from within either bank 0 or bank 1. directly addressing the data memory will always result in bank 0 being accessed irrespective of the value of the bank pointer. accumulator  acc the accumulator is central to the operation of any microcontroller and is closely related with operations carried out by the alu. the accumulator is the place where all intermediate results from the alu are stored. without the accumulator it would be necessary to write the result of each calculation or logical operation such as addition, subtraction, shift, etc., to the data memory resulting in higher programming and timing overheads. data transfer operations usually involve the temporary storage function of the accumulator; for example, when transferring data between one user defined register and another, it is necessary to do this by passing the data through the accumulator as no direct transfer between two registers is permitted. program counter low register  pcl to provide additional program control functions, the low byte of the program counter is made accessible to pro - grammers by locating it within the special purpose area of the data memory. by manipulating this register, direct jumps to other program locations are easily imple - mented. loading a value directly into this pcl register will cause a jump to the specified program memory lo - cation, however, as the register is only 8-bit wide, only jumps within the current program memory page are per - mitted. when such operations are used, note that a dummy cycle will be inserted.  ! "  $ !  %   0  2 5  2 5  2                  2       5    2    *       5    * 7   $   ;   $               h 2 h bank pointer  bp
ht86axx/ht86arxx rev. 1.00 23 march 19, 2010 look-up table registers  tblp, tbhp, tblh these two special function registers are used to control operation of the look-up table which is stored in the pro - gram memory. tblp is the table pointer and indicates the location where the table data is located. its value must be setup before any table read commands are ex - ecuted. its value can be changed, for example using the inc or dec instructions, allowing for easy table data pointing and reading. tblh is the location where the high order byte of the table data is stored after a table read data instruction has been executed. note that the lower order table data byte is transferred to a user de - fined location. watchdog timer register  wdts the watchdog feature of the microcontroller provides an automatic reset function giving the microcontroller a means of protection against spurious jumps to incorrect program memory addresses. to implement this, a timer is provided within the microcontroller which will issue a reset command when its value overflows. to provide variable watchdog timer reset times, the watchdog timer clock source can be divided by various division ra - tios, the value of which is set using the wdts register. by writing directly to this register, the appropriate divi - sion ratio for the watchdog timer clock source can be setup. note that only the lower 3 bits are used to set divi- sion ratios between 1 and 128. status register  status this 8-bit register contains the zero flag (z), carry flag (c), auxiliary carry flag (ac), overflow flag (ov), power down flag (pdf), and watchdog time-out flag (to). these arithmetic/logical operation and system manage- ment flags are used to record the status and operation of the microcontroller. with the exception of the to and pdf flags, bits in the status register can be altered by instructions like most other registers. any data written into the status register will not change the to or pdf flag. in addition, opera - tions related to the status register may give different re - sults due to the different instruction operations. the to flag can be affected only by a system power-up, a wdt time-out or by executing the  clr wdt or halt in - struction. the pdf flag is affected only by executing the halt or  clr wdt instruction or during a system power-up. the z, ov, ac and c flags generally reflect the status of the latest operations.  c is set if an operation results in a carry during an ad - dition operation or if a borrow does not take place dur - ing a subtraction operation; otherwise c is cleared. c is also affected by a rotate through carry instruction.  ac is set if an operation results in a carry out of the low nibbles in addition, or no borrow from the high nib - ble into the low nibble in subtraction; otherwise ac is cleared.  z is set if the result of an arithmetic or logical operation is zero; otherwise z is cleared.  ov is set if an operation results in a carry into the high - est-order bit but not a carry out of the highest-order bit, or vice versa; otherwise ov is cleared.  pdf is cleared by a system power-up or executing the  clr wdt instruction. pdf is set by executing the halt instruction.  to is cleared by a system power-up or executing the  clr wdt or halt instruction. to is set by a wdt time-out. in addition, on entering an interrupt sequence or execut- ing a subroutine call, the status register will not be pushed onto the stack automatically. if the contents of the status registers are important and if the subroutine can corrupt the status register, precautions must be taken to correctly save it. interrupt control register  intc, intch two 8-bit register, known as the intc and intch regis - ters, controls the operation of both external and internal timer interrupts. by setting various bits within these reg - isters using standard bit manipulation instructions, the enable/disable function of the external and timer inter - rupts can be independently controlled. a master inter - rupt bit within this register, the emi bit, acts like a global enable/disable and is used to set all of the interrupt en - able bits on or off. this bit is cleared when an interrupt     8  ( i

&    ' &  % ( $   %    $   ) %  $ * +   ( $ * , - %    $  ! .  ( 
     ) #  ! $ b  #            ) #  ! i    ) #  !    ) # '  ) #  ! & /   % ) 0  !  ( % ) % !  .  (   '    '  ) #  !      !       $   ) #  ! 7     % #      ;         h 2 h  0  2 status register
ht86axx/ht86arxx rev. 1.00 24 march 19, 2010 routine is entered to disable further interrupt and is set by executing the reti instruction. note: in situations where other interrupts may require servicing within present interrupt service rou - tines, the emi bit can be manually set by the pro - gram after the present interrupt service routine has been entered. timer registers all devices contain four 8-bit timers whose associated registers are known as tmr0, tmr1, tmr2 and tmr3, which are the locations where the associated timer's 8-bit value is located. their associated control registers, known as tmr0c, tmr1c, tmr2c and tmr3c, con - tain the setup information for these timers. note that all timer registers can be directly written to in order to preload their contents with fixed data to allow different time intervals to be setup. input/output ports and control registers within the area of special function registers, the i/o registers and their associated control registers play a prominent role. all i/o ports have a designated register correspondingly labeled as pa, pb, pc, pd, pe, etc. these labeled i/o registers are mapped to specific ad - dresses within the data memory as shown in the data memory table, which are used to transfer the appropri- ate output or input data on that port. with each i/o port there is an associated control register labeled pac, pbc, pcc, pdc, pec, etc., also mapped to specific ad- dresses with the data memory. the control register specifies which pins of that port are set as inputs and which are set as outputs. to setup a pin as an input, the corresponding bit of the control register must be set high, for an output it must be set low. during program in - itialisation, it is important to first setup the control regis - ters to specify which pins are outputs and which are inputs before reading data from or writing data to the i/o ports. one flexible feature of these registers is the ability to directly program single bits using the  set [m].i and  clr [m].i instructions. the ability to change i/o pins from output to input and vice-versa by manipulating spe - cific bits of the i/o control registers during normal pro - gram operation is a useful feature of these devices. voice rom data address latch counter registers these are the latch0h/latch0m/latch0l, latch1h/latch1m/latch1l and the voice rom data registers. the voice rom data address latch coun - ter provides the handshaking between the microcontroller and the voice rom, where the voice codes are stored. eight bits of voice rom data will be addressed by using the 21-bit address latch counter, which is composed of latch0h/latch0m/latch0l or latch1h/latch1m/latch1l. after the 8-bit voice rom data is addressed, several instruction cycles of at least 4  s at least, will be required to latch the voice rom data, after which the microcontroller can read the voice data from latchd. voice control and audio output registers  voicec, dal, dah, vol the device includes a single 12-bit current type dac function for driving an external 8  speaker through an external npn transistor. the programmer must write the voice data to the dal/dah registers. a/d converter registers  adrl, adrh, adcr, acsr the device contains a 4-channel 12-bit a/d converter. the correct operation of the a/d requires the use of two data registers, a control register and a clock source reg - ister. it contain a 12-bit a/d converter, there are two data registers, a high byte data register known as adrh, and a low byte data register known as adrl. these are the register locations where the digital value is placed after the completion of an analog to digital conversion cycle. the channel selection and configuration of the a/d con - verter is setup via the control register adcr while the a/d clock frequency is defined by the clock source reg - ister, acsr. input/output ports holtek microcontrollers offer considerable flexibility on their i/o ports. with the input or output designation of ev- ery pin fully under user program control, pull-high op- tions for all ports and wake-up options on certain pins, the user is provided with an i/o structure to meet the needs of a wide range of application possibilities. depending upon which device or package is chosen, the microcontroller range provides 40 bidirectional in - put/output lines labeled with port names pa, pb, pc, pd, pe, etc. these i/o ports are mapped to the ram data memory with specific addresses as shown in the special purpose data memory table. all of these i/o ports can be used for input and output operations. for input operation, these ports are non-latching, which means the inputs must be ready at the t2 rising edge of instruction  mov a,[m] , where m denotes the port ad - dress. for output operation, all the data is latched and remains unchanged until the output latch is rewritten. pull-high resistors many product applications require pull-high resistors for their switch inputs usually requiring the use of an exter - nal resistor. to eliminate the need for these external re - sistors, all i/o pins, when configured as an input have the capability of being connected to an internal pull-high resistor. these pull-high resistors are selectable via configuration options and are implemented using a weak pmos transistor. note that if the pull-high option is
ht86axx/ht86arxx rev. 1.00 25 march 19, 2010 selected, then all i/o pins on that port will be connected to pull-high resistors, individual pins can be selected for pull-high resistor options. port a wake-up each device has a halt instruction enabling the microcontroller to enter a power down mode and pre - serve power, a feature that is important for battery and other low-power applications. various methods exist to wake-up the microcontroller, one of which is to change the logic condition on one of the port a pins from high to low. after a  halt instruction forces the microcontroller into entering a halt condition, the processor will re - main idle or in a low-power state until the logic condition of the selected wake-up pin on port a changes from high to low. this function is especially suitable for applica - tions that can be woken up via external switches. note that each pin on port a can be selected individually to have this wake-up feature. i/o port control registers each i/o port has its own control register pac, pbc, pcc, pdc, pec, etc., to control the input/output config - uration. with this control register, each cmos output or input with or without pull-high resistor structures can be reconfigured dynamically under software control. each pin of the i/o ports is directly mapped to a bit in its asso- ciated port control register. for the i/o pin to function as an input, the corresponding bit of the control register must be written as a 1 . this will then allow the logic state of the input pin to be directly read by instructions. when the corresponding bit of the control register is written as a 0 , the i/o pin will be setup as a cmos out- put. if the pin is currently setup as an output, instructions can still be used to read the output register. however, it should be noted that the program will in fact only read the status of the output data latch and not the actual logic status of the output pin. pin-shared functions the flexibility of the microcontroller range is greatly en - hanced by the use of pins that have more than one func - tion. limited numbers of pins can force serious design constraints on designers but by supplying pins with multi-functions, many of these difficulties can be over - come. for some pins, the chosen function of the multi-function i/o pins is set by configuration options while for others the function is set by application pro - gram control.  a/d inputs the device have 4 a/d converter channel inputs. all of these analog inputs are pin-shared with pc0 to pc3. if these pins are to be used as a/d inputs and not as normal i/o pins then the corresponding bits in the a/d converter control register that must be properly set. there are no configuration options associated with the a/d function. if used as i/o pins, then full pull-high resistor selections remain, however if used as a/d in - puts then any pull-high resistor selections associated with these pins will be automatically disconnected.  serial interface the serial interface are pin-shared with pd0 to pd3. if there are to be used as serial interface inputs and not as normal i/o pins then the corresponding bits in the serial interface control register that must be properly set. there are a configuration option associ - ated with the serial interface function. if used as i/o pins, then full pull-high resistor selections remain, however if used as the serial interface inputs then any pull-high resistor selections associated with these pins will be automatically disconnected.  i/o pin structures the following diagrams illustrate the i/o pin internal structures. as the exact logical construction of the i/o pin may differ from these drawings, they are supplied as a guide only to assist with the functional under - standing of the i/o pins. note also that the specified pins refer to the largest device package, therefore not all pins specified will exist on all devices. programming considerations within the user program, one of the first things to con - sider is port initialization. after a reset, all of the i/o data and port control registers will be set high. this means that all i/o pins will default to an input state, the level of which depends on the other connected circuitry and whether pull-high options have been selected. if the port control registers, pac, pbc, pcc, pdc, pec etc., are then programmed to setup some pins as outputs, these output pins will have an initial high output value unless the associated port data registers, pa, pb, pc, pd, pe, etc., are first programmed. selecting which pins are in - puts and which are outputs can be achieved byte-wide by loading the correct values into the appropriate port control register or by programming individual bits in the port control register using the  set [m].i and clr [m].i instructions. note that when using these bit control instructions, a read-modify-write operation takes place. the microcontroller must first read in the data on the en - tire port, modify it to the required new bit values and then rewrite this data back to the output ports.  *  +  ,  -  *  +  ,  -                )             
#           read/write timing
ht86axx/ht86arxx rev. 1.00 26 march 19, 2010 (              !       j
k   j
k 
  #  5    $ # #  >  !   %        5 $       
  #    !     
  %          
  #    !                   !           5        $ # #  $ % j j  " 9  5 2 l  5 0  3 2 l  3 0 pb/pe input/output ports (    " 9            !       j
k   j
k 
  #  5    $ # #  >  !   %        5 $       
  #    !     
  %          
  #    !                   !           5   
2       5    2 l  ,   
          $ # #  $ % j j  " 9 
2 l 
0  2 l  , pc input/output port      $ %   %               $ %            !     
  #  5    $ # #  >  !   %        5 $       
  #    !     
  %          
  #    !                   !           5    2 l  0      $ # #  $ %  j
k  j  j
k  j (    " 9 pa input/output port
ht86axx/ht86arxx rev. 1.00 27 march 19, 2010 port a has the additional capability of providing wake-up functions. when the device is in the power down mode, various methods are available to wake the device up. one of these is a high to low transition of any of the port a pins. single or multiple pins on port a can be setup to have this function. timers the provision of timers form an important part of any microcontroller, giving the designer a means of carrying out time related functions. the devices in the voice type mcu series contain four count up timers of 8-bit capac- ity. each timer has only one operating mode, which is to act as a general timer. the provision of an internal prescaler to the clock circuitry of the timers gives added range to the timer. configuring the timer input clock source the clock source of timer0/timer1/tmier2 is the system clock divided by four and the clock source of timer3 is the system clock divided by four or the rtc clock which is derived from a external 32khz crystal. a configuration option determines which clock is selected. if the rtc clock is selected then note that it will continue to run when the device is powered down using the halt in - struction. the 8-bit timer clock source is also first di- vided by a prescaler, the division ratio of which is conditioned by the three lower bits of the associated timer control register. timer registers  tmr0, tmr1, tmr2, tmr3 the timer registers are special function registers located in the special purpose data memory and is the place where the actual timer value is stored. the value in the timer registers increases by one each time an internal clock pulse is received. the timer will count from the ini - tial value loaded by the preload register to the full count of ffh at which point the timer overflows and an internal interrupt signal is generated. the timer value will then be reset with the initial preload register value and con - tinue counting.         
  #  2  7  *  7  +  7    #     !                5 $    #     ) # '        $ %   +  
+ l  +  
2  *  
+ l  *  
2  2  
+ l  2  
2   5         )  c   -       #   : *  + l *  + . / <  +   *  *   *  2   *  +   2  *   2  2   2 8-bit timer structure  tmr0, tmr1, tmr2 (    " 9            !       j
k   j
k 
  #  5    $ # #  >  !   %        5 $       
  #    !     
  %          
  #    !                   !           5     2       5   
 ;  
k ;     ;          #      )         $ # #  $ % j j  " 9   2 l   0 
 ;  
k ;     ;     pd input/output port
ht86axx/ht86arxx rev. 1.00 28 march 19, 2010 note that to achieve a maximum full range count of ffh for the 8-bit timer, the preload registers must first be cleared to all zeros. it should be noted that after power-on, the preload registers will be in an unknown condition. note that if the timer counters are in an off condition and data is written to their preload registers, this data will be immediately written into the actual coun - ter. however, if the counter is enabled and counting, any new data written into the preload data register during this period will remain in the preload register and will only be written into the actual counter the next time an overflow occurs. note also that when the timer registers are read, the timer clock will be blocked to avoid errors, however, as this may result in certain timing errors, pro - grammers must take this into account. timer control registers  tmr0c, tmr1c, tmr2c, tmr3c the timers are setup using their respective control regis- ter. these registers are known as tmr0c, tmr1c, tmr2c and tmr3c. it is the timer control register to- gether with its corresponding timer registers that control the full operation of the timer. before the timers can be used, it is essential that the appropriate timer control register is fully programmed with the right data to ensure its correct operation, a process that is normally carried out during program initialization. bits 7 and 6 of the timer control register, which are known as the bit pair tm1/tm0, must be set to 10 re - spectively to ensure correct timer operation. the timer-on bit, which is bit 4 of the timer control register and known as ton, provides the basic on/off control of the respective timer. setting the bit high allows the timer to run, clearing the bit stops the timer. bits 0~2 of the timer control register determine the division ratio of the input clock prescaler. configuring the timer the timer is used to measure fixed time intervals, pro - viding an internal interrupt signal each time the timer overflows. to do this the operating mode select bit pair in the timer control register must be set to the correct value as shown. the timer clock source is further divided by a prescaler, the value of which is determined by the prescaler rate select bits, which are bits 0~2 in the timer control reg- ister. after the other bits in the timer control register have been setup, the enable bit, which is bit 4 of the timer control register, can be set high to enable the timer to run. each time an internal clock cycle occurs, the timer increments by one. when it is full and over- flows, an interrupt signal is generated and the timer will reload the value already loaded into the preload register and continue counting. the interrupt can be disabled by ensuring that the timer interrupt enable bit in the inter - rupt control register, intc, is reset to zero.         
  #  ,  7    #     !                5 $    #     ) # '        $ %   ,  
+ l  ,  
2   5         )  c   -       #   : *  + l *  + . / <  ,   *  ,   2  
 " 9
)  ! $      %   8-bit timer structure  tmr3             
  # #         #     $  % $        4  *       4  +       4  7       4  7  4  * timer mode timing diagram
ht86axx/ht86arxx rev. 1.00 29 march 19, 2010  0   7   2  *  2 7     % #      ;         h 2 h        ) )     # * d     #  2 d      #   %      !       #     2   *  *   *  +   *  ,   * 2 2 * *  2   2  *   2  +   2  ,   2 2 * 2 *        #   #         #   #                  #   #   0    +  0  #  +  0    +  0     % ( $   %  7     % #      ;         h m       h  
+  
*  
2             #           #     2  
+  *  
+  +  
+  ,  
+ 2 2 2 2 * * * *  2  
*  *  
*  +  
*  ,  
* 2 2 * * 2 2 * *  2  
2  *  
2  +  
2  ,  
2 2 * 2 * 2 * 2 *                * d +      * d -      * d       * d * /      * d , +      * d / -      * d * +       * d + . / timer control register  all devices prescaler all of the 8-bit timers possess a prescaler. bits 0~2 of their associated timer control register, define the pre-scaling stages of the internal clock source of the timer. the timer overflow signal can be used to gener- ate signals for the timer interrupt. programming considerations the internal system clock is used as the timer clock source and is therefore synchronized with the overall operation of the microcontroller. in this mode, when the appropriate timer register is full, the microcontroller will generate an internal interrupt signal directing the pro - gram flow to the respective internal interrupt vector. when the timer is read, the clock is blocked to avoid er - rors, however as this may result in a counting error, this should be taken into account by the programmer. care must be taken to ensure that the timers are properly in - itialised before using them for the first time. the associ - ated timer enable bits in the interrupt control register must be properly set otherwise the internal interrupt as- sociated with the timer will remain inactive. it is also im- portant to ensure that an initial value is first loaded into the timer registers before the timer is switched on; this is because after power-on the initial values of the timer registers are unknown. after the timer has been initial- ised the timer can be turned on and off by controlling the enable bit in the timer control register. timer program example the following example program section is based on the devices, which contain a single internal 8-bit timer. pro - gramming the timer for other devices is conducted in a very similar way. the program shows how the timer reg - isters are setup along with how the interrupts are en - abled and managed. also note how the timer is turned on by setting bit 4 of the respective timer control register. the timer can be turned off in a similar way by clearing the same bit. this example program sets the timer to be in the timer mode which uses the internal system clock as their clock source.
ht86axx/ht86arxx rev. 1.00 30 march 19, 2010 include ht86a72.inc jmp begin : org 04h ; external interrupt vectors reti org 08h reti org 0ch reti org 10h ; timer 2 interrupt vector jmp tmr2int ; jump here when timer 2 overflows org 14h reti org 18h reti : ; internal timer 2 interrupt routine tmr2int: : ; timer 2 main program placed here : reti : begin: ; setup timer 2 registers mov a,09bh ; setup timer 2 mov tmr2,a mov a,0097h ; setup timer 2 mov tmr2c,a ; setup timer 2 ; setup interrupt register mov a,01h ; enable master interrupt mov intc,a mov a,01h ; enable timer 2 interrupt mov intch,a :
ht86axx/ht86arxx rev. 1.00 31 march 19, 2010 interrupts interrupts are an important part of any microcontroller system. when an external event or an internal function such as a timer requires microcontroller attention, their corresponding interrupt will enforce a temporary sus - pension of the main program allowing the microcontroller to direct attention to their respective needs. interrupt register overall interrupt control, which means interrupt enabling and flag setting, is controlled using two registers, known as intc and intch, which are located in the data memory. by controlling the appropriate enable bits in these registers each individual interrupt can be enabled or disabled. also when an interrupt occurs, the corre - sponding request flag will be set by the microcontroller. the global enable flag if cleared to zero will disable all interrupts. interrupt operation a timer overflow or the external interrupt line being pulled low will all generate an interrupt request by set - ting their corresponding request flag, if their appropriate interrupt enable bit is set. when this happens, the pro - gram counter, which stores the address of the next in- struction to be executed, will be transferred onto the stack. the program counter will then be loaded with a new address which will be the value of the correspond- ing interrupt vector. the microcontroller will then fetch its next instruction from this interrupt vector. the instruc - tion at this vector will usually be a jmp statement which will take program execution to another section of pro - gram which is known as the interrupt service routine. here is located the code to control the appropriate inter - rupt. the interrupt service routine must be terminated with a reti statement, which retrieves the original pro - gram counter address from the stack and allows the microcontroller to continue with normal execution at the point where the interrupt occurred. the various interrupt enable bits, together with their as - sociated request flags, are shown in the accompanying diagram with their order of priority. once an interrupt subroutine is serviced, all the other in - terrupts will be blocked, as the emi bit will be cleared au - tomatically. this will prevent any further interrupt nesting from occurring. however, if other interrupt requests oc - cur during this interval, although the interrupt will not be immediately serviced, the request flag will still be re - corded. if an interrupt requires immediate servicing while the program is already in another interrupt service routine, the emi bit should be set after entering the rou - tine, to allow interrupt nesting. if the stack is full, the in - terrupt request will not be acknowledged, even if the related interrupt is enabled, until the stack pointer is decremented. if immediate service is desired, the stack must be prevented from becoming full. 1 2    % ( $   %              $ %   g #   #  3   #  * d  ! #   #     #  2 d  ! #   #      #  7    % #      ;         h 2 h  0  2 3 3  3         2       $ %   3   #  * d     #  2 d      #        2       $ %     = $     8 #  ! * d       2 d        3  8 2 8 3 b     #       $ %   3   #  * d     #  2 d      #  3 b     #       $ %     = $     8 #  ! * d       2 d        3  *   * 8       *       $ %   3   #  * d     #  2 d      #        *       $ %     = $     8 #  ! * d       2 d        3  2  interrupt control register
ht86axx/ht86arxx rev. 1.00 32 march 19, 2010 1 2     % ( $   %   0  2 3  +   + 8 , 8 3  ,  3    8       +       $ %   3   #  * d     #  2 d      #        ,       $ %   3   #  * d     #  2 d      #    
           $ %   3   #  7    % #      ;         h 2 h       +       $ %     = $     8 #  ! * d       2 d              ,       $ %     = $     8 #  ! * d       2 d          
           $ %     = $     8 #  ! * d       2 d        7    % #      ;         h 2 h intch register $        # #  
#              $  # #        
#          )  '    3 3  3               $ %   # #  ! >  !  $        # #        #        
     3   #     $  # #  3  2  & ' 3  +  3  *  3  ,        2      $ %     = $     8 #  !   2 8       *      $ %     = $     8 #  !   * 8       +      $ %     = $     8 #  !   + 8       ,      $ %     = $     8 #  !   , 8 3 b     #       $ %    = $     8 #  !  3  8 3     
          $ %     = $     8 #  !   8 interrupt structure
ht86axx/ht86arxx rev. 1.00 33 march 19, 2010 interrupt priority interrupts, occurring in the interval between the rising edges of two consecutive t2 pulses, will be serviced on the latter of the two t2 pulses, if the corresponding inter - rupts are enabled. in case of simultaneous requests, the accompanying table shows the priority that is applied. interrupt source interrupt vector priority external interrupt 04h 1 timer 0 overflow 08h 2 timer 1 overflow 0ch 3 timer 2 overflow 10h 4 timer 3 overflow 14h 5 a/d converter overflow 18h 6 in cases where both external the timer interrupts are en - abled and where an external and timer interrupt occur simultaneously, the external interrupt will always have priority and will therefore be serviced first. suitable masking of the individual interrupts using the intc and intch registers can prevent simultaneous occur - rences. external interrupt each device contains a single external interrupt function controlled by the external pin, int . for an external inter- rupt to occur, the corresponding external interrupt en- able bit must be first set. this is bit 1 of the intc register and known as eei. an external interrupt is triggered by an external edge transition on the external interrupt pin int , after which the related interrupt request flag, eif, which is bit 4 of intc, will be set. a configuration option exists for the external interrupt pin to determine the type of external edge transition which will trigger an external interrupt. there are two options available, a low going edge or both high and low going edges. when the mas - ter interrupt and external interrupt bits are enabled, the stack is not full and an active edge transition, as setup in the configuration options, occurs on the int pin, a sub - routine call to the corresponding external interrupt vec - tor, which is located at 04h, will occur. after entering the interrupt execution routine, the corresponding interrupt request flag, eif, will be reset and the emi bit will be cleared to disable other interrupts. timer interrupt for a timer generated interrupt to occur, the correspond - ing timer interrupt enable bit must be first set. each de - vice contains four 8-bit timers whose corresponding interrupt enable bits are known as et0i, et1i, et2i and et3i and are located in the intc and intch registers. each timer also has a corresponding timer interrupt re - quest flag, which are known as t0f, t1f, t2f and t3f, also located in the intc and intch registers. when the master interrupt and corresponding timer interrupt en - able bits are enabled, the stack is not full, and when the corresponding timer overflows a subroutine call to the corresponding timer interrupt vector will occur. the cor - responding program memory vector locations for timer 0, timer1, timer 2 and timer 3 are 08h, 0ch, 10h and 14h. after entering the interrupt execution routine, the corresponding interrupt request flags, t0f, t1f, t2f or t3f will be reset and the emi bit will be cleared to dis - able other interrupts. a/d converter interrupt the internal a/d converter interrupt is initialised by set - ting the a/d interrupt request flag (adf:bit6 of intch). when the interrupt is enabled, and the stack is not full and the adf bit is set, a subroutine call to location  18h will occur. the related interrupt request flag, adf, will be reset and the emi bit cleared to disable further interrupts. programming considerations by disabling the interrupt enable bits, a requested inter - rupt can be prevented from being serviced, however, once an interrupt request flag is set, it will remain in this condition in the intc or intch register until the corre- sponding interrupt is serviced or until the request flag is cleared by a software instruction. it is recommended that programs do not use the call subroutine instruction within the interrupt subroutine. interrupts often occur in an unpredictable manner or need to be serviced immediately in some applications. if only one stack is left and the interrupt is not well con- trolled, the original control sequence will be damaged once a  call subroutine is executed in the interrupt subroutine. all of these interrupts have the capability of waking up the mcu when in the power down mode. only the pro - gram counter is pushed onto the stack. if the contents of the register or status register are altered by the interrupt service program, which may corrupt the desired control sequence, then the contents should be saved in ad - vance.
ht86axx/ht86arxx rev. 1.00 34 march 19, 2010 reset and initialisation a reset function is a fundamental part of any microcontroller ensuring that the device can be set to some predetermined condition irrespective of outside parameters. the most important reset condition is after power is first applied to the microcontroller. in this case, internal circuitry will ensure that the microcontroller, af - ter a short delay, will be in a well defined state and ready to execute the first program instruction. after this power-on reset, certain important internal registers will be set to defined states before the program com - mences. one of these registers is the program counter, which will be reset to zero forcing the microcontroller to begin program execution from the lowest program memory address. in addition to the power-on reset, situations may arise where it is necessary to forcefully apply a reset condition when the microcontroller is running. one example of this is where after power has been applied and the microcontroller is already running, the res line is force - fully pulled low. in such a case, known as a normal oper - ation reset, some of the microcontroller registers remain unchanged allowing the microcontroller to proceed with normal operation after the reset line is allowed to return high. another type of reset is when the watchdog timer overflows and resets the microcontroller. all types of re- set operations result in different register conditions be- ing setup. another reset exists in the form of a low voltage reset, lvr, where a full reset, similar to the res reset is imple- mented in situations where the power supply voltage falls below a certain threshold. reset functions there are five ways in which a microcontroller reset can occur, through events occurring both internally and ex - ternally:  power-on reset the most fundamental and unavoidable reset is the one that occurs after power is first applied to the microcontroller. as well as ensuring that the program memory begins execution from the first memory ad - dress, a power-on reset also ensures that certain other registers are preset to known conditions. all the i/o port and port control registers will power up in a high condition ensuring that all pins will be first set to inputs. although the microcontroller has an internal rc reset function, if the vdd power supply rise time is not fast enough or does not stabilise quickly at power-on, the internal reset function may be incapable of providing proper reset operation. for this reason it is recom - mended that an external rc network is connected to the res pin, whose additional time delay will ensure that the res pin remains low for an extended period to allow the power supply to stabilise. during this time delay, normal operation of the microcontroller will be inhibited. after the res line reaches a certain voltage value, the reset delay time t rstd is invoked to provide an extra delay time after which the microcontroller will begin normal operation. the abbreviation sst in the figures stands for system start-up timer. for most applications a resistor connected between vdd and the res pin and a capacitor connected be - tween vss and the res pin will provide a suitable ex - ternal reset circuit. any wiring connected to the res pin should be kept as short as possible to minimise any stray noise interference. for applications that operate within an environment where more noise is present the enhanced reset cir- cuit shown is recommended. more information regarding external reset circuits is located in application note ha0075e on the holtek website.  res pin reset this type of reset occurs when the microcontroller is already running and the res pin is forcefully pulled low by external hardware such as an external switch. in this case as in the case of other reset, the program counter will reset to zero and program execution initi - ated from this point.  3  (            $       #       2 @ 1  (        power-on reset timing chart  3  2 @ *  8 * 2 2   (   (   2 @ 2 *  8 * 2   enhanced reset circuit  3           $       #       2 @ 1  (   2 @ -  (        res reset timing chart  3  (   (   2 @ *  8 * 2 2   basic reset circuit
ht86axx/ht86arxx rev. 1.00 35 march 19, 2010  low voltage reset  lvr the microcontroller contains a low voltage reset circuit in order to monitor the supply voltage of the device, which is selected via a configuration option. if the supply voltage of the device drops to within a range of 0.9v~v lvr such as might occur when changing the bat - tery, the lvr will automatically reset the device inter - nally. the lvr includes the following specifications: for a valid lvr signal, a low voltage, i.e., a voltage in the range between 0.9v~v lvr must exist for greater than the value t lvr specified in the a.c. characteristics. if the low voltage state does not exceed 1ms, the lvr will ignore it and will not perform a reset function.  watchdog time-out reset during normal operation the watchdog time-out reset during normal opera - tion is the same as a hardware res pin reset except that the watchdog time-out flag to will be set to 1.  watchdog time-out reset during power down the watchdog time-out reset during power down is a little different from other kinds of reset. most of the conditions remain unchanged except that the pro - gram counter and the stack pointer will be cleared to 0 and the to flag will be set to 1 . refer to the a.c. characteristics for t sst details. reset initial conditions the different types of reset described affect the reset flags in different ways. these flags, known as pdf and to are located in the status register and are controlled by various microcontroller operations, such as the power down function or watchdog timer. the reset flags are shown in the table: to pdf reset conditions 0 0 res reset during power-on u u res or lvr reset during normal operation 1 u wdt time-out reset during normal operation 1 1 wdt time-out reset during power down note: u stands for unchanged the following table indicates the way in which the vari - ous components of the microcontroller are affected after a power-on reset occurs. item condition after reset program counter reset to zero interrupts all interrupts will be disabled wdt clear after reset, wdt begins counting timer all timer will be turned off prescaler the timer prescaler will be cleared input/output ports i/o ports will be setup as inputs stack pointer stack pointer will point to the top of the stack & (           $       #            low voltage reset timing chart          $           $       #            wdt time-out reset during normal operation timing chart          $           $      wdt time-out reset during power down timing chart
ht86axx/ht86arxx rev. 1.00 36 march 19, 2010 the different kinds of resets all affect the internal registers of the microcontroller in different ways. to ensure reliable continuation of normal program execution after a reset occurs, it is important to know what condition the microcontroller is in after a particular reset occurs. the following table describes how each type of reset affects each of the microcontroller internal registers. note that where more than one package type exists the table will reflect the situation for the larger package type. register reset (power-on) wdt time-out (normal operation) res reset (normal operation) res reset (halt) wdt time-out from halt mp0 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu mp1 xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu bp 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu acc xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu pcl 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 tblp xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu tblh xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu wdts 0000 0111 0000 0111 0000 0111 0000 0111 uuuu uuuu status   00 xxxx   1u uuuu   uu uuuu   01 uuuu   11 uuuu intc  000 0000  000 0000  000 0000  000 0000  uuu uuuu tmr0 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu tmr0c 00 0 1000 00  0 1000 00  0 1000 00  0 1000 uu  u uuuu tmr1 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu tmr1c 00 0 1000 00  0 1000 00  0 1000 00  0 1000 uu  u uuuu pa 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pac 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pb 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pbc 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pc 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pcc 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pd 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pdc 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pe 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu pec 1111 1111 1111 1111 1111 1111 1111 1111 uuuu uuuu tmr2 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu tmr2c 00 0 1000 00  0 1000 00  0 1000 00  0 1000 uu  u uuuu tmr3 0000 0000 0000 0000 0000 0000 0000 0000 uuuu uuuu tmr3c 00 0 1000 00  0 1000 00  0 1000 00  0 1000 uu  u uuuu intch  000  000  000  000  000  000  000  000  uuu  uuu tbhp xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu dal xxxx  uuuu  uuuu  uuuu  uuuu  d ah xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu vol xxx   xxx   xxx   xxx   uuu   voicec 0000  00 0000  00 0000  00 0000  00 uuuu  uu
ht86axx/ht86arxx rev. 1.00 37 march 19, 2010 register reset (power-on) wdt time-out (normal operation) res reset (normal operation) res reset (halt) wdt time-out from halt latch0h xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu latch0m xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu latch0l xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu latch1h xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu latch1m xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu latch1l xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu latchd xxxx xxxx uuuu uuuu uuuu uuuu uuuu uuuu uuuu uuuu adrl xxxx  xxxx  xxxx  xxxx  uuuu  adrh xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu adcr 0100 0000 0100 0000 0100 0000 0100 0000 uuuu uuuu acsr   00   00   00   00   uu lvdc 000x 0  00 000x 0  00 000x 0  00 000x 0  00 uuux u  uu sbcr 0110 0000 0110 0000 0110 0000 0110 0000 uuuu uuuu sbdr xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx uuuu uuuu note: u stands for unchanged x stands for unknown  stands for undefined
ht86axx/ht86arxx rev. 1.00 38 march 19, 2010 oscillator various oscillator options offer the user a wide range of functions according to their various application require - ments. two types of system clocks can be selected while various clock source options for the watchdog timer are provided for maximum flexibility. all oscillator options are selected through the configuration options. the two methods of generating the system clock are:  external crystal/resonator oscillator  external rc oscillator one of these two methods must be selected using the configuration options. more information regarding the oscillator is located in application note ha0075e on the holtek website. external crystal/resonator oscillator the simple connection of a crystal across osc1 and osc2 will create the necessary phase shift and feed - back for oscillation, and will normally not require exter - nal capacitors. however, for some crystals and most resonator types, to ensure oscillation and accurate fre - quency generation, it may be necessary to add two small value external capacitors, c1 and c2. the exact values of c1 and c2 should be selected in consultation with the crystal or resonator manufacturer s specifica - tion. the external parallel feedback resistor, rp, is nor - mally not required but in some cases may be needed to assist with oscillation start up. internal ca, cb, rf typical values @ 5v, 25 c ca cb rf 11~13pf 13~15pf 800k oscillator internal component values external rc oscillator using the external system rc oscillator requires that an external resistor is connected. for the mask version de - vice a value of between 120k  and 280k  is required for the opt device a value of between 40k  and 90k  is required. this external resistor is connected between osc1 and vss. a clock signal, with a frequency of the generated system clock divided by 4, will be provided on osc2 as an output which can be used for external syn - chronisation purposes. note that as the osc2 output is an nmos open-drain type, a pull high resistor should be connected if it to be used to monitor the internal fre - quency. although this is a cost effective oscillator con - figuration, the oscillation frequency can vary with vdd, temperature and process variations and is therefore not suitable for applications where timing is critical or where accurate oscillator frequencies are required. note that it is the only microcontroller internal circuitry together with the external resistor, that determines the frequency of the oscillator. watchdog timer oscillator the wdt oscillator is a fully self-contained free running on-chip rc oscillator with a typical period of 65  sat5v requiring no external components. when the device en- ters the power down mode, the system clock will stop running but the wdt oscillator continues to free-run and to keep the watchdog active. however, to preserve power in certain applications the wdt oscillator can be disabled via a configuration option. rtc oscillator a 32khz crystal can be connected to pins xin and xout to implement an rtc oscillator. the rtc oscilla - tor is used as a clock source for timer/event counter 3 but must be first enabled using a configuration option. if the configuration option enables the rtc oscillator then it will automatically become the clock source for the timer/event counter 3. the rtc oscillator will continue to operate even if the halt instruction is executed and the device is powered down. it may be necessary to connect two small capacitors between xin, xout and ground for correct operation of the rtc.  
*  
+  )        #     $    1 !  %  !  . ,  * $ . .      $  * 3 $ 
*
+

  % 7   d * @   %        # #       = $    @ + @  #   $ !       '   
*   
+  %          %               %         )    $  0 % 8 @ crystal/resonator oscillator  
*   
 
+ )  c   -  7      %       external rc oscillator 9  "  9  7 , + 0 /  > ? rtc oscillator
ht86axx/ht86arxx rev. 1.00 39 march 19, 2010 power down mode and wake-up power down mode all of the holtek microcontrollers have the ability to enter a power down mode, also known as the halt mode or sleep mode. when the device enters this mode, the nor - mal operating current, will be reduced to an extremely low standby current level. this occurs because when the device enters the power down mode, the system oscillator is stopped which reduces the power consump - tion to extremely low levels, however, as the device maintains its present internal condition, it can be woken up at a later stage and continue running, without requir - ing a full reset. this feature is extremely important in ap - plication areas where the mcu must have its power supply constantly maintained to keep the device in a known condition but where the power supply capacity is limited such as in battery applications. entering the power down mode there is only one way for the device to enter the power down mode and that is to execute the  halt instruc - tion in the application program. when this instruction is executed, the following will occur:  the system oscillator will stop running and the appli - cation program will stop at the halt instruction.  the data memory contents and registers will maintain their present condition.  the wdt will be cleared and resume counting if the wdt clock source is selected to come from the wdt oscillator. the wdt will stop if its clock source origi- nates from the system clock.  the i/o ports will maintain their present condition.  in the status register, the power down flag, pdf, will be set and the watchdog time-out flag, to, will be cleared. standby current considerations as the main reason for entering the power down mode is to keep the current consumption of the mcu to as low a value as possible, perhaps only in the order of several micro-amps, there are other considerations which must also be taken into account by the circuit designer if the power consumption is to be minimized. special atten - tion must be made to the i/o pins on the device. all high-impedance input pins must be connected to either a fixed high or low level as any floating input pins could create internal oscillations and result in increased cur - rent consumption. care must also be taken with the loads, which are connected to i/os, which are setup as outputs. these should be placed in a condition in which minimum current is drawn or connected only to external circuits that do not draw current, such as other cmos inputs. also note that additional standby current will also be required if the configuration options have enabled the watchdog timer internal oscillator. wake-up after the system enters the power down mode, it can be woken up from one of various sources listed as follows:  an external reset  an external falling edge on port a  a system interrupt  a wdt overflow if the system is woken up by an external reset, the de - vice will experience a full system reset, however, if the device is woken up by a wdt overflow, a watchdog timer reset will be initiated. although both of these wake-up methods will initiate a reset operation, the ac - tual source of the wake-up can be determined by exam - ining the to and pdf flags. the pdf flag is cleared by a system power-up or executing the clear watchdog timer instructions and is set when executing the  halt instruction. the to flag is set if a wdt time-out occurs, and causes a wake-up that only resets the program counter and stack pointer, the other flags remain in their original status. each pin on port a can be setup via an individual config - uration option to permit a negative transition on the pin to wake-up the system. when a port a pin wake-up oc- curs, the program will resume execution at the instruc- tion following the  halt instruction. if the system is woken up by an interrupt, then two possi- ble situations may occur. the first is where the related interrupt is disabled or the interrupt is enabled but the stack is full, in which case the program will resume exe- cution at the instruction following the  halt instruction. in this situation, the interrupt which woke-up the device will not be immediately serviced, but will rather be ser - viced later when the related interrupt is finally enabled or when a stack level becomes free. the other situation is where the related interrupt is enabled and the stack is not full, in which case the regular interrupt response takes place. if an interrupt request flag is set to 1 be - fore entering the power down mode, the wake-up func - tion of the related interrupt will be disabled. no matter what the source of the wake-up event is, once a wake-up situation occurs, a time period equal to 1024 system clock periods will be required before normal sys - tem operation resumes. however, if the wake-up has originated due to an interrupt, the actual interrupt sub - routine execution will be delayed by an additional one or more cycles. if the wake-up results in the execution of the next instruction following the  halt instruction, this will be executed immediately after the 1024 system clock period delay has ended.
ht86axx/ht86arxx rev. 1.00 40 march 19, 2010 watchdog timer the watchdog timer is provided to prevent program malfunctions or sequences from jumping to unknown lo - cations, due to certain uncontrollable external events such as electrical noise. it operates by providing a de - vice reset when the wdt counter overflows. the wdt clock is supplied by one of two sources selected by con - figuration option: its own self-contained dedicated inter - nal wdt oscillator, or the instruction clock which is the system clock divided by 4. note that if the wdt configu - ration option has been disabled, then any instruction re - lating to its operation will result in no operation. the internal wdt oscillator has an approximate period of 65  s at a supply voltage of 5v. if selected, it is first di - vided by 256 via an 8-stage counter to give a nominal period of 17ms. note that this period can vary with vdd, temperature and process variations. for longer wdt time-out periods the wdt prescaler can be utilized. by writing the required value to bits 0, 1 and 2 of the wdts register, known as ws0, ws1 and ws2, longer time-out periods can be achieved. with ws0, ws1 and ws2 all equal to 1, the division ratio is 1:128 which gives a maxi - mum time-out period of about 2.1s. a configuration option can select the instruction clock, which is the system clock divided by 4, as the wdt clock source instead of the internal wdt oscillator. if the in- struction clock is used as the clock source, it must be noted that when the system enters the power down mode, as the system clock is stopped, then the wdt clock source will also be stopped. therefore the wdt will lose its protecting purposes. in such cases the sys- tem cannot be restarted by the wdt and can only be re- started using external signals. for systems that operate in noisy environments, using the internal wdt oscillator is therefore the recommended choice. under normal program operation, a wdt time-out will initialise a device reset and set the status bit to. how - ever, if the system is in the power down mode, when a wdt time-out occurs, only the program counter and stack pointer will be reset. three methods can be adopted to clear the contents of the wdt and the wdt prescaler. the first is an external hardware reset, which means a low level on the res pin, the second is using the watchdog software instructions and the third is via a  halt instruction. there are two methods of using software instructions to clear the watchdog timer, one of which must be chosen by configuration option. the first option is to use the sin - gle  clr wdt instruction while the second is to use the two commands  clr wdt1 and  clr wdt2 . for the first option, a simple execution of  clr wdt will clear the wdt while for the second option, both clr wdt1 and  clr wdt2 must both be executed to successfully clear the wdt. note that for this second option, if  clr wdt1 is used to clear the wdt, succes - sive executions of this instruction will have no effect, only the execution of a  clr wdt2 instruction will clear the wdt. similarly, after the  clr wdt2 instruc - tion has been executed, only a successive  clr wdt1 instruction can clear the watchdog timer.   + 4 5  &  % ( $   %   0  2     %      #           #      + 2 2 2 2 * * * *   * 2 2 * * 2 2 * *   2 2 * 2 * 2 * 2 *               * d *       * d +       * d -       * d        * d * /       * d , +       * d / -       * d * +  7   $     *   2 watchdog timer register
ht86axx/ht86arxx rev. 1.00 41 march 19, 2010 voice output voice control the voice control register controls the voice rom circuit and the dac circuit and selects the voice rom latch counter. if the dac circuit is not enabled, any dah/dal outputs will be invalid. writing a 1 to the dac bit will enable the dac circuit, while writing a 0 to the dac bit will disable the dac circuit. if the voice rom circuit is not enabled, then voice rom data cannot be accessed. writing a 1 to the vromc bit will enable the voice rom circuit, while writing a 0 to the vromc bit will disable the voice rom circuit. the latch bit deter- mines which voice rom address latch counter will be used as the voice rom address latch counter. audio output and volume control  dal, dah, vol the audio output is 12-bits wide whose highest 8-bits are written into the dah register and whose lowest four bits are written into the highest four bits of the dal regis- ter. bits 0~3 of the dal register are always read as zero. there are 8 levels of volume which are setup using the vol register. only the highest 3-bits of this register are used for volume control, the other bits are not used and read as zero.      
$         :  + . / < 0            #       *   " 9          $    2 l   +    
#     $   
#           % 
)  ! $       %  
&      *  8 #  !
&      +  8 #  ! *    +      $    
&  
&   )  c   -         # #       
#     $   
)  ! $       %   watchdog timer  , 1  6   % ( $   %   0  2 & 
>
(   

 2 3 7  2 3  8   7     % #      ;         ?   
 3   #  * d     #  2 d      #  (          3   #  * d     #  2 d      #  7     % #      ;         ?   (        
$       #    * d       &      * 2 d       &      2  '     % #  )     3   #  * d     #  2 d      #   '     % #  )      $    3   #  * d     #  2 d      #   %    " %  , +  > ? 
     #  3   #  * d     #  2 d      #  voice control register 5    % ( $   %   0  2 7   $   ;         h 2 h  ,  +  *  2 $   $  % $  5 $ ( $   .    !  .  ( 5      7  % ( $   %  5    % ( $   %   0  2  * *  * 2  1   $   $  % $  5 $ ( $   .    !  .  ( 5     $ (   % ( $   %   ,   % ( $   %   0  2 7   $   ;         h 2 h   # $       #       . 3 ) %   !    .  % ( $   %   0  /  .  - (  & + (  & * (  & 2
ht86axx/ht86arxx rev. 1.00 42 march 19, 2010 voice rom data address latch counter the voice rom address is 21-bits wide and therefore requires three registers to store the address. there are two sets of three registers to store this address, which are latch0h/latch0m/latch0l and latch1h/ latch1m/latch1l. the 21-bit address stored in one set of these three registers is used to access the 8-bit voice code data in the voice rom. after the 8-bit voice rom data is addressed, a few instruction cycles, of at least 4us dura - tion, are needed to latch the voice rom data. after this the microcontroller can read the voice data from the latchd register. example: read an 8-bit voice rom data which is located at address 000007h by address latch 0 set [26h].2 ; enable voice rom circuit mov a, 07h ; mov latch0l, a ; set latch0l to 07h mov a, 00h ; mov latch0m, a ; set latch0m to 00h mov a, 00h ; mov latch0h, a ; set latch0h to 00h call delay ; delay a short period of time mov a, latchd ; get voice data at 000007h power amplifier each device contains an audio power amplifier which is an integrated class ab monophonic type speaker driver. it has the properties of high s/n ratio, high slew rate, low distortion, large output voltage swing, excellent power supply ripple rejection, low power consumption, low standby current and power off control etc. aud in: audio input v bias : speaker non-inverting input voltage reference sp+:audio positive output sp-: audio negative output outp rising time (t r ) when amp_en enables the power amplifer, note that it requires a certain time before it can output fully on the outp pin. however, this delay time depends on the value of c1. the c1 capacitor is connected between vbias and vss.   *   + ( 5   * 2     $   5        4   6 3 7   k
* 2 @ *  8   6 3 7  "       capacitor 0.1f1 f 4.7f1 0 f t r voltage 2.2v 15ms 30ms 90ms 185ms 3v 15ms 30ms 90ms 185ms 4 15ms 30ms 90ms 185ms
ht86axx/ht86arxx rev. 1.00 43 march 19, 2010 sp+/sp- am p_en t r t r for battery based applications, power consumption is a key issue, therefore the amplifier should be turned off when in the standby state. in order to eliminate any speaker sound bursts while turning the amplifier on, the application circuit, which will incorporate a capacitance value of c1, should be adjusted in accordance with the speaker s audio frequency response. a greater value of c1 will improve the noise burst while turning on the am - plifier. the recommended operation sequence is: turn on: audio signal standby (1/2vdd) enable am - plifier wait t r for amplifier ready audio output turn off: audio signal finished disable amplifier wait t r for amplifier off audio signal off if the application is not powered by batteries and there is no problem with amplifier on/off issues, a capacitor value of 0.1  f for c1 is recommended. analog to digital converter the need to interface to real world analog signals is a common requirement for many electronic systems. however, to properly process these signals by a microcontroller, they must first be converted into digital signals by a/d converters. by integrating the a/d con- version electronic circuitry into the microcontroller, the need for external components is reduced significantly with the corresponding follow-on benefits of lower costs and reduced component space requirements. a/d overview the devices contain a 4-channel analog to digital con- verter which can directly interface to external analog sig- nals, such as that from sensors or other control signals and convert these signals directly into either a 12-bit dig - ital value. the following diagram shows the overall internal struc - ture of the a/d converter, together with its associated registers. a/d converter data registers  adrl, adrh the devices have a 12-bit a/d converter, two registers are required, a high byte register, known as adrh , and a low byte register, known as adrl. after the conver- sion process takes place, these registers can be directly read by the microcontroller to obtain the digitized con- version value. they use two a/d converter data regis- ters, note that only the high byte register adrh utilises its full 8-bit contents. the low byte register adrl uti- lises only 4 of its 8-bit contents as it contains only the lower 4 bit of the 12-bit converted value. 
  $    )  
 +  l  , +
     !      
(        )       #   !    &   >          !       
 2 l 
 +
 2 l
 *     3 

   !        
)  ! $     5   
   #    #    5            3  )
     5   
#             
2  7 2 
*  7 * 
+  7 + 
,  7 , a/d converter structure
ht86axx/ht86arxx rev. 1.00 44 march 19, 2010 in the following table, d0~d11 are the a/d conversion data result bits. register bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 adrl d3 d2 d1 d0  adrh d11 d10 d9 d8 d7 d6 d5 d4 a/d data register a/d converter control register  adcr to control the function and operation of the a/d con - verter, a control register known as adcr is provided. this 8-bit register defines functions such as the selec - tion of which analog channel is connected to the internal a/d converter, which pins are used as analog inputs and which are used as normal i/os as well as controlling the start function and monitoring the a/d converter end of conversion status. one section of this register contains the bits acs1~acs0 which define the channel number. as each of the devices contains only one actual analog to digital converter circuit, each of the individual 4 analog inputs must be routed to the converter. it is the function of the acs1~acs0 bits in the adcr register to determine which analog channel is actually connected to the inter- nal a/d converter. the adcr control register also contains the pcr2~pcr0 bits which determine which pins on port c are used as analog inputs for the a/d converter and which pins are to be used as normal i/o pins. note that if the pcr2~pcr0 bits are all set to zero, then all the port c pins will be setup as normal i/os and the internal a/d converter circuitry will be powered off to reduce the power consumption. the start bit in the adcr register is used to start and reset the a/d converter. when the microcontroller sets this bit from low to high and then low again, an analog to digital conversion cycle will be initiated. when the start bit is brought from low to high but not low again, the eoc bit in the adcr register will be set high and the analog to digital converter will be reset. it is the start bit that is used to control the overall on/off operation of the internal analog to digital converter. the eoc bit in the adcr register is used to indicate when the analog to digital conversion process is com - plete. this bit will be automatically cleared to zero by the microcontroller after a conversion cycle has ended. in addition, the corresponding a/d interrupt request flag will be set in the interrupt control register, and if the inter - rupts are enabled, an appropriate internal interrupt sig - nal will be generated. this a/d internal interrupt signal will direct the program flow to the associated a/d inter - nal interrupt address for processing. if the a/d internal interrupt is disabled, the microcontroller can be used to poll the eoc bit in the adcr register to check whether it has been cleared as an alternative method of detecting the end of an a/d conversion cycle. a/d converter clock source register  acsr the clock source for the a/d converter, which originates from the system clock f osc , is first divided by a division ratio, the value of which is determined by the adcs1 and adcs0 bits in the acsr register. although the a/d clock source is determined by the sys- tem clock f osc , and by bits adcs1 and adcs0, there are some limitations on the maximum a/d clock source speed that can be selected. refer to the following table. acs1 acs0 analog channel 0 0 an0 0 1 an1 1 0 an2 1 1 an3 acs table: a/d channel select table  5    % ( $   %    #            #         #    )      
     #   0  2     
 + 
 * 
 2
 *
 2    
        #   )  ! $              #    )       
     #  3  )           ) #  ! * d      )                      '     !      %  !     2 d    )                                          2    *    2  d       2    *  d                        3 
5    h * h 3 
5 7     % #              h 2 h adcr register
ht86axx/ht86arxx rev. 1.00 45 march 19, 2010 pcr2 pcr1 pcr0 3 2 1 0 0 0 0 pc3 pc2 pc1 pc0 0 0 1 pc3 pc2 pc1 an0 0 1 0 pc3 pc2 an1 an0 0 1 1 pc3 an2 an1 an0 1 0 0 an3 an2 an1 an0 pcr table: port a/d channel configuration table f osc a/d clock period (t ad ) adcs1, adcs0=01 (f osc /2) adcs1, adcs0=10 (f osc /8) adcs1, adcs0=00 (f osc /32) adcs1, adcs0=11 4mhz 500ns 2s8 s  6mhz 333ns 1.3s 5.3s  8mhz 250ns 1s4 s  a/d clock period examples   &   % ( $   %    #                #     $     0  2  3   
 * 
 2 
 * 2 2 * * 
 2 2 * 2 * d  )  
 + d  )  
  d  )  
 , + d  7     % #      7     % #      ;         h 2 h 8           $    #  acsr register a/d input pins all of the a/d analog input pins are pin-shared with the i/o pins on port c. bits pcr2~pcr0 in the acsr regis - ters, not configuration options, determine whether the input pins are setup as normal port c input/output pins or whether they are setup as analog inputs. in this way, pins can be changed under program control to change their function from normal i/o operation to analog inputs and vice versa. pull-high resistors, which are setup through configuration options, apply to the input pins only when they are used as normal i/o pins, if setup as a/d inputs the pull-high resistors will be automatically disconnected. note that it is not necessary to first setup the a/d pin as an input in the pbc port control register to enable the a/d input, when the pcr2~pcr0 bits en - able an a/d input, the status of the port control register will be overridden. the vdd power supply pin is used as the a/d converter reference voltage, and as such analog inputs must not be allowed to exceed this value. appropriate measures should also be taken to ensure that the vdd pin remains as stable and noise free as possible. initialising the a/d converter the internal a/d converter must be initialised in a spe - cial way. each time the port c a/d channel selection bits are modified by the program, the a/d converter must be re-initialised. if the a/d converter is not initialized after the channel selection bits are changed, the eocb flag may have an undefined value, which may produce a false end of conversion signal. to initialize the a/d con - verter after the channel selection bits have changed, then, within a time frame of one to ten instruction cycles, the start bit in the adcr register must first be set high and then immediately cleared to zero. this will ensure that the eocb flag is correctly set to a high condition. summary of a/d conversion steps the following summarizes the individual steps that should be executed in order to implement an a/d con - version process.  step 1 select the required a/d conversion clock by correctly programming bits adcs1 and adcs0 in the acsr register.
ht86axx/ht86arxx rev. 1.00 46 march 19, 2010  step 2 select which channel is to be connected to the internal a/d converter by correctly programming the acs1~acs0 bits which are also contained in the adcr register.  step 3 select which pins on port c are to be used as a/d in - puts and configure them as a/d input pins by correctly programming the pcr2~pcr0 bits in the adcr reg - ister. note that this step can be combined with step 2 into adcr registers programming operation.  step 4 the analog to digital conversion process can now be initialised by setting the start bit in the adcr regis - ter from 0 to 1 and then to 0 again. note that this bit should have been originally set to 0.  step 5 to check when the analog to digital conversion pro - cess is complete, the eocb bit in the adcr register can be polled. the conversion process is complete when this bit goes low. when this occurs the a/d data registers adrl and adrh can be read to obtain the conversion value. the following timing diagram shows graphically the vari - ous stages involved in an analog to digital conversion process and its associated timing.  
              
              
             2 2 2 5 2 2 2 5 2 * 2 5     3 
5 
 + l 
 2
 * l
 2  '         3  )         * d    )    
  )  ! $     + d    #       # !      #       )                             % #  !        , +    2 * * 5 2 2 2 5       )                       2 2 2 5 * @  
 %       $ %         + @               % '     ) )         $    % '      $  %   * 2 2 5 2 2 * 5       )                        m       3  )         3  )                        !   '                 $        #     )         
 2 l 
 +          !              % #  !        , +          % #  !        , +    a/d conversion timing
ht86axx/ht86arxx rev. 1.00 47 march 19, 2010 spi serial interface the device includes a single spi serial interfaces. the spi interface is a full duplex serial data link, originally designed by motorola, which allows multiple devices connected to the same spi bus to communicate with each other. the devices communicate using a mas - ter/slave technique where only the single master device can initiate a data transfer. a simple four line signal bus is used for all communication. the four spi lines are shared with i/o pins pd0~pd3, the function of which is chosen using a configuration option. spi interface communication four lines are used for spi communication known as sdi - serial data input, sdo - serial data output, sck - serial clock and scs - slave select. note that the con - dition of the slave select line is conditioned by the csen bit in the sbcr control register. if the csen bit is high then the scs line is active while if the bit is low then the scs line will be in a floating condition. the following timing diagram depicts the basic timing protocol of the spi bus.  0  /  .  -  ,  +  *  2  5    :               !      <  " 9     5 $ ) )    " 9  &       5 $   " 9           #              #  5  $      
#   
k
#     #     
+
*
2  5 3 7      #  5 $    8 #  !  5 3 7        5   
 &  8 #  !   8  ;        5 3 7 3 7 7         5          5    3   #        #  
 3 7           #  
 3 7  5 3 7  ;        ;       spi block diagram  5
  3 8 " &   5    3 8 " &  7   d  h " h       $    !  @
k   *  2  5 3 7  & 
 3 7 
 &   8  0  /  .  -  ,  +  *  2 2 * * 2 2 2 2 2  0  /  .  -  ,  +  *  2 " " " " " " " "  5
  d   3   &  5 " 
 7    &   3 g    3   5    d   3   &  5 "      3 g    3   0   2  /   *  .   +  -   ,  ,   -  +   .  *   /  2   0     0   2  /   *  .   +  -   ,  ,   -  +   .  *   /  2   0    
k 

ht86axx/ht86arxx rev. 1.00 48 march 19, 2010 &    % ( $   %   0  2
k   *  2  5 3 7  & 
 3 7 
 &   8                 8 #  ! 2 d  7     % #    * d                %      % #         
# #     5   2 d 
# #     )    * d 
# #             #        !  #  3   #        #   5   2 d  
  ) #    ! * d  3   #    5  &  5  8      5   2 d  &  5     )   )     * d    5     )   )          #  5 $   3   #        #   5   2 d       #  * d  3   #        %     $ % 
 3 7             #    5  $       5          ;    $      d  )          ;    $      d  )     -       ;    $      d  )     * /  #       * 2 2 * *  2 2 * 2 *
#     $       #     5   2 d  )    a )  c   - * d  )    a )  c  spi interface control register 
k 
        *   /  0   2  /   *  .   +  -   ,  ,   -  +   .  *   /  2   0  0   2  /   *  .   +  -   ,  ,   -  +   .  2   0  5 3 7 a 
 3 7 a  *    '             5    5 3 7 a  * ; 
 3 7 a  2    '             5    :  )  % $ # #    !   < 
k spi bus timing spi registers there are two registers associated with the spi inter - face. these are the sbcr register which is the control register and the sbdr which is the data register. the sbcr register is used to setup the required setup pa - rameters for the spi bus and also used to store associ - ated operating flags, while the sbdr register is used for data storage. after power on, the contents of the sbdr register will be in an unknown condition while the sbcr register will de - fault to the condition below: cks m1 m0 sben mls csen wcol trf 01100000 note that data written to the sbdr register will only be written to the txrx buffer, whereas data read from the sbdr register will actual be read from the register. spi bus enable/disable to enable the spi bus and csen=1, the sck, sdi, sdo and scs lines should all be zero, then wait for data to be written to the sbdr (txrx bufffer) register. for the master mode, after data has been written to the sbdr (txrx buffer) register then transmission or re - ception will start automatically. when all the data has been transferred the trf bit should be set. for the slave mode, when clock pulses are received on sck, data in the txrx buffer will be shifted out or data on sdi will be shifted in. to disable the spi bus sck, sdi, sdo, scs floating. spi operation all communication is carried out using the 4-line inter - face for both master or slave mode. the timing diagram shows the basic operation of the bus.
ht86axx/ht86arxx rev. 1.00 49 march 19, 2010 the csen bit in the sbcr register controls the overall function of the spi interface. setting this bit high, will en - able the spi interface by allowing the scs line to be ac - tive, which can then be used to control the spi interface. if the csen bit is low, the spi interface will be disabled and the scs line will be in a floating condition and can therefore not be used for control of the spi interface. the sben bit in the sbcr register must also be high which will place the sdi line in a floating condition and the sdo line high. if in master mode the sck line will be either high or low depending upon the clock polarity con - figuration option. if in slave mode the sck line will be in a floating condition. if sben is low then the bus will be disabled and scs, sdi, sdo and sck will all be in a floating condition. in the master mode the master will always generate the clock signal. the clock and data transmission will be ini - tiated after data has been written to the sbdr register. in the slave mode, the clock signal will be received from an external master device for both data transmission or reception. the following sequences show the order to be followed for data transfer in both master and slave mode:  master mode step 1. select the clock source using the cks bit in the sbcr control register step 2. setup the m0 and m1 bits in the sbcr control register to select the master mode and the required baud rate. values of 00, 01 or 10 can be selected. step 3. setup the csen bit and setup the mls bit to choose if the data is msb or lsb first, this must be same as the slave device. step 4. setup the sben bit in the sbcr control register to enable the spi interface. step 5. for write operations: write the data to the sbdr register, which will actually place the data into the txrx buffer. then use the sck and scs lines to output the data. goto to step6.for read operations: the data transferred in on the sdi line will be stored in the txrx buffer until all the data has been received at which point it will be latched into the sbdr register. step 6. check the wcol bit, if set high then a collision error has occurred so return to step5. if equal to zero then go to the following step. step 7. check the trf bit or wait for an sbi serial bus. step 8. read data from the sbdr register. step 9. clear trf. step10. goto step 5.  slave mode step 1. the cks bit has a don t care value in the slave mode. step 2. setup the m0 and m1 bits to 00 to select the slave mode. the cks bit is don t care. step 3. setup the csen bit and setup the mls bit to choose if the data is msb or lsb first, this must be same as the master device. step 4. setup the sben bit in the sbcr control register to enable the spi interface. step 5. for write operations: write data to the sbcr register, which will actually place the data into the txrx register, then wait for the master clock and scs signal. after this goto step 6. for read operations: the data transferred in on the sdi line will be stored in the txrx buffer until all the data has been received at which point it will be latched into the sbdr register. step 6. check the wcol bit, if set high then a collision error has occurred so return to step5. if equal to zero then go to the following step. step 7. check the trf bit or wait for an sbi serial bus. step 8. read data from the sbdr register. step 9. clear trf step10. goto step 5 spi configuration options several configuration options exist for the spi interface function which must be setup during device program - ming. the first is a configuration to select the pd0~pd3 pins to be used as the spi interface pins. another option is to enable the operation of the wcol, write collision bit, in the sbcr register. another option exists to select the clock polarity of the sck line. a configuration option also exists to disable or enable the operation of the csen bit in the sbcr register. if the configuration op- tion disables the csen bit then this bit cannot be used to affect overall control of the spi interface. error detection the wcol bit in the sbcr register is provided to indi - cate errors during data transfer. the bit is set by the se - rial interface but must be cleared by the application program. this bit indicates a data collision has occurred which happens if a write to the sbdr register takes place during a data transfer operation and will prevent the write operation from continuing. the bit will be set high by the serial interface but has to be cleared by the user application program. the overall function of the wcol bit can be disabled or enabled by a configuration option. programming considerations when the device is placed into the power down mode note that data reception and transmission will continue. the trf bit is used to generate an interrupt when the data has been transferred or received.
ht86axx/ht86arxx rev. 1.00 50 march 19, 2010 low voltage detect function a low voltage detect function is implemented within the microcontroller. the lvd function is controlled using the lvdc register and configuration options. to enable the lvd function, both the lvd configuration option should be enabled and the lven bit should be set high. after setting the lven bit high, the circuit requires about 100  s to stabilise. after this time has elapsed, the lvfg bit can be monitored to look for low voltage conditions. the lvs0 and lvs1 bits are used to define the lvd voltage threshold level, however configuration options can also be used to define this voltage. a configuration option is used to decide whether these two register bits or the configuration option is used to define the lvd voltage threshold level. as the low voltage detector circuitry will consume a certain amount of power, the lven bit can be reset to zero to turn off the lvd internal circuitry to reduce power consumption.   5   % ( $   %   0  2 & ( 3 7 & (  * & (  2 & ( 8 g & (   #   !     #    7     % #      ;         h 2 h & '  ( #   !          3   #  * d     #  2 d      #  & '  ( #   !          &   # * d  & 5  7  %   #   !      #        2 d  & 5  7  #   !        #        7     % #      ;          h 2 h & (  * 2 2 * * & (  2 2 * 2 * & (   ( #   !  + @ + ( + @ , ( + @ - ( + @ . ( low voltage detect control register  lvdc & ( 3 7  5   & (   3   # 
)  ! $       %   & (  8 $     " 9 & (  2  & (  *  5   & (   ( #   !   &   #
)  ! $       %   & (  ( #   !   &   # & (   ( #   !   &   #  $       #    & (     ) ) & ( 8 g lvd block diagram
ht86axx/ht86arxx rev. 1.00 51 march 19, 2010 configuration options configuration options refer to certain options within the mcu that are programmed into the device during the program - ming process. during the development process, these options are selected using the ht-ide software development tools. as these options are programmed into the device using the hardware programming tools, once they are selected they cannot be changed later by the application software. no. options i/o options 1 pa0~pa7: wake-up enable or disable (bit option) 2 pa0~pa7: pull-high enable or disable (bit option) 3 pb0~pb7: pull-high enable or disable (bit option) 4 pc0~pc7: pull-high enable or disable (bit option) 5 pd0~pd7: pull-high enable or disable (bit option) 6 pe0~pe7: pull-high enable or disable (bit option) 7 pd pin shared function select: select pd3~pd0 as i/o pins or as serial interface function oscillation option 8 osc type selection: rc or crystal 9 rtc: enable or disable interrupt option 10 int triggering edge: falling or both watchdog options 11 wdt: enable or disable 12 wdt clock source: wdrosc or t1 13 clrwdt instructions: 1 or 2 instructions low voltage reset option 14 lvr select: enable or disable low voltage detect option 15 lvd voltage: 2.2v~2.5v 16 lvd select: enable or disable 17 lvd voltage level control select: register bits or configuration option serial interface option 18 serial interface cpol: falling edge or rising edge 19 serial interface wcol: enable or disable 20 serial interface csen: enable or disable
application circuits ht86axx/ht86arxx rev. 1.00 52 march 19, 2010 "  6  7 2 @ *  8  3  (   (    7  * 2 2   (   2 @ *  8 * 2 2  8 (   (   * 2  - 0  8 2 @ *  8   k   4           +        +         (   (   (   * (    "  6  "  ( 5   . 2    2 l  0  5 2 l  5 0 
2 l 
0   2 l   0  3 2 l  3 0 * 2  8  
+  
*   
(   * (    "  6  7 2 @ *  8  3  (   (    7  * 2 2   (   2 @ *  8 * 2 2  8 (   (   * 2  - 0  8 2 @ *  8   k   4           +        +         (   (   (   * (    "  6  "  ( 5   . 2    2 l  0  5 2 l  5 0 
2 l 
0   2 l   0  3 2 l  3 0 * 2  8  
+  
* (   * (    -  > ? l    > ?
ht86axx/ht86arxx rev. 1.00 53 march 19, 2010 instruction set introduction central to the successful operation of any microcontroller is its instruction set, which is a set of pro - gram instruction codes that directs the microcontroller to perform certain operations. in the case of holtek microcontrollers, a comprehensive and flexible set of over 60 instructions is provided to enable programmers to implement their application with the minimum of pro - gramming overheads. for easier understanding of the various instruction codes, they have been subdivided into several func - tional groupings. instruction timing most instructions are implemented within one instruc - tion cycle. the exceptions to this are branch, call, or ta - ble read instructions where two instruction cycles are required. one instruction cycle is equal to 4 system clock cycles, therefore in the case of an 8mhz system oscillator, most instructions would be implemented within 0.5  s and branch or call instructions would be im - plemented within 1  s. although instructions which re - quire one more cycle to implement are generally limited to the jmp, call, ret, reti and table read instruc- tions, it is important to realize that any other instructions which involve manipulation of the program counter low register or pcl will also take one more cycle to imple- ment. as instructions which change the contents of the pcl will imply a direct jump to that new address, one more cycle will be required. examples of such instruc- tions would be  clr pcl or  mov pcl, a . for the case of skip instructions, it must be noted that if the re- sult of the comparison involves a skip operation then this will also take one more cycle, if no skip is involved then only one cycle is required. moving and transferring data the transfer of data within the microcontroller program is one of the most frequently used operations. making use of three kinds of mov instructions, data can be transferred from registers to the accumulator and vice-versa as well as being able to move specific imme - diate data directly into the accumulator. one of the most important data transfer applications is to receive data from the input ports and transfer data to the output ports. arithmetic operations the ability to perform certain arithmetic operations and data manipulation is a necessary feature of most microcontroller applications. within the holtek microcontroller instruction set are a range of add and subtract instruction mnemonics to enable the necessary arithmetic to be carried out. care must be taken to en - sure correct handling of carry and borrow data when re - sults exceed 255 for addition and less than 0 for subtraction. the increment and decrement instructions inc, inca, dec and deca provide a simple means of increasing or decreasing by a value of one of the values in the destination specified. logical and rotate operations the standard logical operations such as and, or, xor and cpl all have their own instruction within the holtek microcontroller instruction set. as with the case of most instructions involving data manipulation, data must pass through the accumulator which may involve additional programming steps. in all logical data operations, the zero flag may be set if the result of the operation is zero. another form of logical data manipulation comes from the rotate instructions such as rr, rl, rrc and rlc which provide a simple means of rotating one bit right or left. different rotate instructions exist depending on pro - gram requirements. rotate instructions are useful for serial port programming applications where data can be rotated from an internal register into the carry bit from where it can be examined and the necessary serial bit set high or low. another application where rotate data operations are used is to implement multiplication and division calculations. branches and control transfer program branching takes the form of either jumps to specified locations using the jmp instruction or to a sub- routine using the call instruction. they differ in the sense that in the case of a subroutine call, the program must return to the instruction immediately when the sub - routine has been carried out. this is done by placing a return instruction ret in the subroutine which will cause the program to jump back to the address right after the call instruction. in the case of a jmp instruction, the program simply jumps to the desired location. there is no requirement to jump back to the original jumping off point as in the case of the call instruction. one special and extremely useful set of branch instructions are the conditional branches. here a decision is first made re - garding the condition of a certain data memory or indi - vidual bits. depending upon the conditions, the program will continue with the next instruction or skip over it and jump to the following instruction. these instructions are the key to decision making and branching within the pro - gram perhaps determined by the condition of certain in - put switches or by the condition of internal data bits.
ht86axx/ht86arxx rev. 1.00 54 march 19, 2010 bit operations the ability to provide single bit operations on data mem - ory is an extremely flexible feature of all holtek microcontrollers. this feature is especially useful for output port bit programming where individual bits or port pins can be directly set high or low using either the set [m].i or  clr [m].i instructions respectively. the fea - ture removes the need for programmers to first read the 8-bit output port, manipulate the input data to ensure that other bits are not changed and then output the port with the correct new data. this read-modify-write pro - cess is taken care of automatically when these bit oper - ation instructions are used. table read operations data storage is normally implemented by using regis - ters. however, when working with large amounts of fixed data, the volume involved often makes it inconve - nient to store the fixed data in the data memory. to over - come this problem, holtek microcontrollers allow an area of program memory to be setup as a table where data can be directly stored. a set of easy to use instruc - tions provides the means by which this fixed data can be referenced and retrieved from the program memory. other operations in addition to the above functional instructions, a range of other instructions also exist such as the  halt in - struction for power-down operations and instructions to control the operation of the watchdog timer for reliable program operations under extreme electric or electro - magnetic environments. for their relevant operations, refer to the functional related sections. instruction set summary the following table depicts a summary of the instruction set categorised according to function and can be con - sulted as a basic instruction reference using the follow - ing listed conventions. table conventions: x: bits immediate data m: data memory address a: accumulator i: 0~7 number of bits addr: program memory address mnemonic description cycles flag affected arithmetic add a,[m] addm a,[m] add a,x adc a,[m] adcm a,[m] sub a,x sub a,[m] subm a,[m] sbc a,[m] sbcm a,[m] daa [m] add data memory to acc add acc to data memory add immediate data to acc add data memory to acc with carry add acc to data memory with carry subtract immediate data from the acc subtract data memory from acc subtract data memory from acc with result in data memory subtract data memory from acc with carry subtract data memory from acc with carry, result in data memory decimal adjust acc for addition with result in data memory 1 1 note 1 1 1 note 1 1 1 note 1 1 note 1 note z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov z, c, ac, ov c logic operation and a,[m] or a,[m] xor a,[m] andm a,[m] orm a,[m] xorm a,[m] and a,x or a,x xor a,x cpl [m] cpla [m] logical and data memory to acc logical or data memory to acc logical xor data memory to acc logical and acc to data memory logical or acc to data memory logical xor acc to data memory logical and immediate data to acc logical or immediate data to acc logical xor immediate data to acc complement data memory complement data memory with result in acc 1 1 1 1 note 1 note 1 note 1 1 1 1 note 1 z z z z z z z z z z z increment & decrement inca [m] inc [m] deca [m] dec [m] increment data memory with result in acc increment data memory decrement data memory with result in acc decrement data memory 1 1 note 1 1 note z z z z
ht86axx/ht86arxx rev. 1.00 55 march 19, 2010 mnemonic description cycles flag affected rotate rra [m] rr [m] rrca [m] rrc [m] rla [m] rl [m] rlca [m] rlc [m] rotate data memory right with result in acc rotate data memory right rotate data memory right through carry with result in acc rotate data memory right through carry rotate data memory left with result in acc rotate data memory left rotate data memory left through carry with result in acc rotate data memory left through carry 1 1 note 1 1 note 1 1 note 1 1 note none none c c none none c c data move mov a,[m] mov [m],a mov a,x move data memory to acc move acc to data memory move immediate data to acc 1 1 note 1 none none none bit operation clr [m].i set [m].i clear bit of data memory set bit of data memory 1 note 1 note none none branch jmp addr sz [m] sza [m] sz [m].i snz [m].i siz [m] sdz [m] siza [m] sdza [m] call addr ret ret a,x reti jump unconditionally skip if data memory is zero skip if data memory is zero with data movement to acc skip if bit i of data memory is zero skip if bit i of data memory is not zero skip if increment data memory is zero skip if decrement data memory is zero skip if increment data memory is zero with result in acc skip if decrement data memory is zero with result in acc subroutine call return from subroutine return from subroutine and load immediate data to acc return from interrupt 2 1 note 1 note 1 note 1 note 1 note 1 note 1 note 1 note 2 2 2 2 none none none none none none none none none none none none none table read tabrdc [m] tabrdl [m] read table (current page) to tblh and data memory read table (last page) to tblh and data memory 2 note 2 note none none miscellaneous nop clr [m] set [m] clr wdt clr wdt1 clr wdt2 swap [m] swapa [m] halt no operation clear data memory set data memory clear watchdog timer pre-clear watchdog timer pre-clear watchdog timer swap nibbles of data memory swap nibbles of data memory with result in acc enter power down mode 1 1 note 1 note 1 1 1 1 note 1 1 none none none to, pdf to, pdf to, pdf none none to, pdf note: 1. for skip instructions, if the result of the comparison involves a skip then two cycles are required, if no skip takes place only one cycle is required. 2. any instruction which changes the contents of the pcl will also require 2 cycles for execution. 3. for the  clr wdt1 and  clr wdt2 instructions the to and pdf flags may be affected by the execution status. the to and pdf flags are cleared after both  clr wdt1 and  clr wdt2 instructions are consecutively executed. otherwise the to and pdf flags remain unchanged.
instruction definition adc a,[m] add data memory to acc with carry description the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the accumulator. operation acc  acc+[m]+c affected flag(s) ov, z, ac, c adcm a,[m] add acc to data memory with carry description the contents of the specified data memory, accumulator and the carry flag are added. the result is stored in the specified data memory. operation [m]  acc+[m]+c affected flag(s) ov, z, ac, c add a,[m] add data memory to acc description the contents of the specified data memory and the accumulator are added. the result is stored in the accumulator. operation acc  acc + [m] affected flag(s) ov, z, ac, c add a,x add immediate data to acc description the contents of the accumulator and the specified immediate data are added. the result is stored in the accumulator. operation acc  acc+x affected flag(s) ov, z, ac, c addm a,[m] add acc to data memory description the contents of the specified data memory and the accumulator are added. the result is stored in the specified data memory. operation [m]  acc + [m] affected flag(s) ov, z, ac, c and a,[m] logical and data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical and op - eration. the result is stored in the accumulator. operation acc  acc and [m] affected flag(s) z and a,x logical and immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical and operation. the result is stored in the accumulator. operation acc  acc and x affected flag(s) z andm a,[m] logical and acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical and op - eration. the result is stored in the data memory. operation [m]  acc and [m] affected flag(s) z ht86axx/ht86arxx rev. 1.00 56 march 19, 2010
call addr subroutine call description unconditionally calls a subroutine at the specified address. the program counter then in - crements by 1 to obtain the address of the next instruction which is then pushed onto the stack. the specified address is then loaded and the program continues execution from this new address. as this instruction requires an additional operation, it is a two cycle instruc - tion. operation stack  program counter + 1 program counter  addr affected flag(s) none clr [m] clear data memory description each bit of the specified data memory is cleared to 0. operation [m]  00h affected flag(s) none clr [m].i clear bit of data memory description bit i of the specified data memory is cleared to 0. operation [m].i  0 affected flag(s) none clr wdt clear watchdog timer description the to, pdf flags and the wdt are all cleared. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf clr wdt1 pre-clear watchdog timer description the to, pdf flags and the wdt are all cleared. note that this instruction works in conjunc- tion with clr wdt2 and must be executed alternately with clr wdt2 to have effect. re- petitively executing this instruction without alternately executing clr wdt2 will have no effect. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf clr wdt2 pre-clear watchdog timer description the to, pdf flags and the wdt are all cleared. note that this instruction works in conjunc - tion with clr wdt1 and must be executed alternately with clr wdt1 to have effect. re - petitively executing this instruction without alternately executing clr wdt1 will have no effect. operation wdt cleared to  0 pdf  0 affected flag(s) to, pdf ht86axx/ht86arxx rev. 1.00 57 march 19, 2010
cpl [m] complement data memory description each bit of the specified data memory is logically complemented (1 s complement). bits which previously contained a 1 are changed to 0 and vice versa. operation [m]  [m] affected flag(s) z cpla [m] complement data memory with result in acc description each bit of the specified data memory is logically complemented (1 s complement). bits which previously contained a 1 are changed to 0 and vice versa. the complemented result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc  [m] affected flag(s) z daa [m] decimal-adjust acc for addition with result in data memory description convert the contents of the accumulator value to a bcd ( binary coded decimal) value re - sulting from the previous addition of two bcd variables. if the low nibble is greater than 9 or if ac flag is set, then a value of 6 will be added to the low nibble. otherwise the low nibble remains unchanged. if the high nibble is greater than 9 or if the c flag is set, then a value of 6 will be added to the high nibble. essentially, the decimal conversion is performed by add - ing 00h, 06h, 60h or 66h depending on the accumulator and flag conditions. only the c flag may be affected by this instruction which indicates that if the original bcd sum is greater than 100, it allows multiple precision decimal addition. operation [m]  acc + 00h or [m]  acc + 06h or [m]  acc + 60h or [m]  acc + 66h affected flag(s) c dec [m] decrement data memory description data in the specified data memory is decremented by 1. operation [m]  [m]  1 affected flag(s) z deca [m] decrement data memory with result in acc description data in the specified data memory is decremented by 1. the result is stored in the accu - mulator. the contents of the data memory remain unchanged. operation acc  [m]  1 affected flag(s) z halt enter power down mode description this instruction stops the program execution and turns off the system clock. the contents of the data memory and registers are retained. the wdt and prescaler are cleared. the power down flag pdf is set and the wdt time-out flag to is cleared. operation to  0 pdf  1 affected flag(s) to, pdf ht86axx/ht86arxx rev. 1.00 58 march 19, 2010
inc [m] increment data memory description data in the specified data memory is incremented by 1. operation [m]  [m]+1 affected flag(s) z inca [m] increment data memory with result in acc description data in the specified data memory is incremented by 1. the result is stored in the accumu - lator. the contents of the data memory remain unchanged. operation acc  [m]+1 affected flag(s) z jmp addr jump unconditionally description the contents of the program counter are replaced with the specified address. program execution then continues from this new address. as this requires the insertion of a dummy instruction while the new address is loaded, it is a two cycle instruction. operation program counter  addr affected flag(s) none mov a,[m] move data memory to acc description the contents of the specified data memory are copied to the accumulator. operation acc  [m] affected flag(s) none mov a,x move immediate data to acc description the immediate data specified is loaded into the accumulator. operation acc  x affected flag(s) none mov [m],a move acc to data memory description the contents of the accumulator are copied to the specified data memory. operation [m]  acc affected flag(s) none nop no operation description no operation is performed. execution continues with the next instruction. operation no operation affected flag(s) none or a,[m] logical or data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical or oper - ation. the result is stored in the accumulator. operation acc  acc or [m] affected flag(s) z ht86axx/ht86arxx rev. 1.00 59 march 19, 2010
or a,x logical or immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical or op - eration. the result is stored in the accumulator. operation acc  acc or x affected flag(s) z orm a,[m] logical or acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical or oper - ation. the result is stored in the data memory. operation [m]  acc or [m] affected flag(s) z ret return from subroutine description the program counter is restored from the stack. program execution continues at the re - stored address. operation program counter  stack affected flag(s) none ret a,x return from subroutine and load immediate data to acc description the program counter is restored from the stack and the accumulator loaded with the specified immediate data. program execution continues at the restored address. operation program counter  stack acc  x affected flag(s) none reti return from interrupt description the program counter is restored from the stack and the interrupts are re-enabled by set- ting the emi bit. emi is the master interrupt global enable bit. if an interrupt was pending when the reti instruction is executed, the pending interrupt routine will be processed be- fore returning to the main program. operation program counter  stack emi  1 affected flag(s) none rl [m] rotate data memory left description the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. operation [m].(i+1)  [m].i; (i = 0~6) [m].0  [m].7 affected flag(s) none rla [m] rotate data memory left with result in acc description the contents of the specified data memory are rotated left by 1 bit with bit 7 rotated into bit 0. the rotated result is stored in the accumulator and the contents of the data memory re - main unchanged. operation acc.(i+1)  [m].i; (i = 0~6) acc.0  [m].7 affected flag(s) none ht86axx/ht86arxx rev. 1.00 60 march 19, 2010
rlc [m] rotate data memory left through carry description the contents of the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into bit 0. operation [m].(i+1)  [m].i; (i = 0~6) [m].0  c c  [m].7 affected flag(s) c rlca [m] rotate data memory left through carry with result in acc description data in the specified data memory and the carry flag are rotated left by 1 bit. bit 7 replaces the carry bit and the original carry flag is rotated into the bit 0. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.(i+1)  [m].i; (i = 0~6) acc.0  c c  [m].7 affected flag(s) c rr [m] rotate data memory right description the contents of the specified data memory are rotated right by 1 bit with bit 0 rotated into bit 7. operation [m].i  [m].(i+1); (i = 0~6) [m].7  [m].0 affected flag(s) none rra [m] rotate data memory right with result in acc description data in the specified data memory and the carry flag are rotated right by 1 bit with bit 0 ro- tated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i  [m].(i+1); (i = 0~6) acc.7  [m].0 affected flag(s) none rrc [m] rotate data memory right through carry description the contents of the specified data memory and the carry flag are rotated right by 1 bit. bit 0 replaces the carry bit and the original carry flag is rotated into bit 7. operation [m].i  [m].(i+1); (i = 0~6) [m].7  c c  [m].0 affected flag(s) c rrca [m] rotate data memory right through carry with result in acc description data in the specified data memory and the carry flag are rotated right by 1 bit. bit 0 re - places the carry bit and the original carry flag is rotated into bit 7. the rotated result is stored in the accumulator and the contents of the data memory remain unchanged. operation acc.i  [m].(i+1); (i = 0~6) acc.7  c c  [m].0 affected flag(s) c ht86axx/ht86arxx rev. 1.00 61 march 19, 2010
sbc a,[m] subtract data memory from acc with carry description the contents of the specified data memory and the complement of the carry flag are sub - tracted from the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  [m]  c affected flag(s) ov, z, ac, c sbcm a,[m] subtract data memory from acc with carry and result in data memory description the contents of the specified data memory and the complement of the carry flag are sub - tracted from the accumulator. the result is stored in the data memory. note that if the re - sult of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m]  acc  [m]  c affected flag(s) ov, z, ac, c sdz [m] skip if decrement data memory is 0 description the contents of the specified data memory are first decremented by 1. if the result is 0 the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m]  [m]  1 skip if [m] = 0 affected flag(s) none sdza [m] skip if decrement data memory is zero with result in acc description the contents of the specified data memory are first decremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specified data memory contents remain unchanged. as this requires the insertion of a dummy in- struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation acc  [m]  1 skip if acc = 0 affected flag(s) none set [m] set data memory description each bit of the specified data memory is set to 1. operation [m]  ffh affected flag(s) none set [m].i set bit of data memory description bit i of the specified data memory is set to 1. operation [m].i  1 affected flag(s) none ht86axx/ht86arxx rev. 1.00 62 march 19, 2010
siz [m] skip if increment data memory is 0 description the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation [m]  [m]+1 skip if [m] = 0 affected flag(s) none siza [m] skip if increment data memory is zero with result in acc description the contents of the specified data memory are first incremented by 1. if the result is 0, the following instruction is skipped. the result is stored in the accumulator but the specified data memory contents remain unchanged. as this requires the insertion of a dummy in - struction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc  [m]+1 skip if acc = 0 affected flag(s) none snz [m].i skip if bit i of data memory is not 0 description if bit i of the specified data memory is not 0, the following instruction is skipped. as this re - quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is 0 the program proceeds with the following instruction. operation skip if [m].i  0 affected flag(s) none sub a,[m] subtract data memory from acc description the specified data memory is subtracted from the contents of the accumulator. the result is stored in the accumulator. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  [m] affected flag(s) ov, z, ac, c subm a,[m] subtract data memory from acc with result in data memory description the specified data memory is subtracted from the contents of the accumulator. the result is stored in the data memory. note that if the result of subtraction is negative, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation [m]  acc  [m] affected flag(s) ov, z, ac, c sub a,x subtract immediate data from acc description the immediate data specified by the code is subtracted from the contents of the accumu - lator. the result is stored in the accumulator. note that if the result of subtraction is nega - tive, the c flag will be cleared to 0, otherwise if the result is positive or zero, the c flag will be set to 1. operation acc  acc  x affected flag(s) ov, z, ac, c ht86axx/ht86arxx rev. 1.00 63 march 19, 2010
swap [m] swap nibbles of data memory description the low-order and high-order nibbles of the specified data memory are interchanged. operation [m].3~[m].0  [m].7 ~ [m].4 affected flag(s) none swapa [m] swap nibbles of data memory with result in acc description the low-order and high-order nibbles of the specified data memory are interchanged. the result is stored in the accumulator. the contents of the data memory remain unchanged. operation acc.3 ~ acc.0  [m].7 ~ [m].4 acc.7 ~ acc.4  [m].3 ~ [m].0 affected flag(s) none sz [m] skip if data memory is 0 description if the contents of the specified data memory is 0, the following instruction is skipped. as this requires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruc - tion. operation skip if [m] = 0 affected flag(s) none sza [m] skip if data memory is 0 with data movement to acc description the contents of the specified data memory are copied to the accumulator. if the value is zero, the following instruction is skipped. as this requires the insertion of a dummy instruc - tion while the next instruction is fetched, it is a two cycle instruction. if the result is not 0 the program proceeds with the following instruction. operation acc  [m] skip if [m] = 0 affected flag(s) none sz [m].i skip if bit i of data memory is 0 description if bit i of the specified data memory is 0, the following instruction is skipped. as this re- quires the insertion of a dummy instruction while the next instruction is fetched, it is a two cycle instruction. if the result is not 0, the program proceeds with the following instruction. operation skip if [m].i = 0 affected flag(s) none tabrdc [m] read table (current page) to tblh and data memory description the low byte of the program code (current page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m]  program code (low byte) tblh  program code (high byte) affected flag(s) none tabrdl [m] read table (last page) to tblh and data memory description the low byte of the program code (last page) addressed by the table pointer (tblp) is moved to the specified data memory and the high byte moved to tblh. operation [m]  program code (low byte) tblh  program code (high byte) affected flag(s) none ht86axx/ht86arxx rev. 1.00 64 march 19, 2010
xor a,[m] logical xor data memory to acc description data in the accumulator and the specified data memory perform a bitwise logical xor op - eration. the result is stored in the accumulator. operation acc  acc xor [m] affected flag(s) z xorm a,[m] logical xor acc to data memory description data in the specified data memory and the accumulator perform a bitwise logical xor op - eration. the result is stored in the data memory. operation [m]  acc xor [m] affected flag(s) z xor a,x logical xor immediate data to acc description data in the accumulator and the specified immediate data perform a bitwise logical xor operation. the result is stored in the accumulator. operation acc  acc xor x affected flag(s) z ht86axx/ht86arxx rev. 1.00 65 march 19, 2010
package information 44-pin qfp (10mm  10mm) outline dimensions symbol dimensions in mm min. nom. max. a1 3  13.4 b 9.9  10.1 c1 3  13.4 d 9.9  10.1 e  0.8  f  0.3  g 1.9  2.2 h  2.7 i 0.25  0.5 j 0.73  0.93 k 0.1  0.2 l  0.1   0 7 ht86axx/ht86arxx rev. 1.00 66 march 19, 2010 , - * * * - - 5 + + * + 3 8 g >  n k  , , + ,
 &
64-pin lqfp (10mm  10mm) outline dimensions symbol dimensions in mm min. nom. max. a 11.9  12.1 b 9.9  10.1 c 11.9  12.1 d 9.9  10.1 e  0.5  f  0.2  g 1.35  1.45 h  1.6 i  0.1  j 0.45  0.75 k 0.1  0.2  0 7 ht86axx/ht86arxx rev. 1.00 67 march 19, 2010 -  - 1 , , , + / - * * / * 0 5
 3 8 g >  n k 
ht86axx/ht86arxx rev. 1.00 68 march 19, 2010 copyright  2010 by holtek semiconductor inc. the information appearing in this data sheet is believed to be accurate at the time of publication. however, holtek as - sumes no responsibility arising from the use of the specifications described. the applications mentioned herein are used solely for the purpose of illustration and holtek makes no warranty or representation that such applications will be suitable without further modification, nor recommends the use of its products for application that may present a risk to human life due to malfunction or otherwise. holtek s products are not authorized for use as critical components in life support devices or systems. holtek reserves the right to alter its products without prior notification. for the most up-to-date information, please visit our web site at http://www.holtek.com.tw. holtek semiconductor inc. (headquarters) no.3, creation rd. ii, science park, hsinchu, taiwan tel: 886-3-563-1999 fax: 886-3-563-1189 http://www.holtek.com.tw holtek semiconductor inc. (taipei sales office) 4f-2, no. 3-2, yuanqu st., nankang software park, taipei 115, taiwan tel: 886-2-2655-7070 fax: 886-2-2655-7373 fax: 886-2-2655-7383 (international sales hotline) holtek semiconductor inc. (shenzhen sales office) 5f, unit a, productivity building, no.5 gaoxin m 2nd road, nanshan district, shenzhen, china 518057 tel: 86-755-8616-9908, 86-755-8616-9308 fax: 86-755-8616-9722 holtek semiconductor (usa), inc. (north america sales office) 46729 fremont blvd., fremont, ca 94538, usa tel: 1-510-252-9880 fax: 1-510-252-9885 http://www.holtek.com


▲Up To Search▲   

 
Price & Availability of HT86AR72

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X